本文整理汇总了Java中org.apache.bcel.classfile.Method.isProtected方法的典型用法代码示例。如果您正苦于以下问题:Java Method.isProtected方法的具体用法?Java Method.isProtected怎么用?Java Method.isProtected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Method
的用法示例。
在下文中一共展示了Method.isProtected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyzeMethod
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method)
throws CFGBuilderException, DataflowAnalysisException {
boolean sawCallToEquals = false;
JavaClass jclass = classContext.getJavaClass();
ConstantPoolGen cpg = classContext.getConstantPoolGen();
MethodGen methodGen = classContext.getMethodGen(method);
// Report at most one String comparison per method.
// We report the first highest priority warning.
stringComparison = null;
refComparison = null;
CFG cfg = classContext.getCFG(method);
DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
ExceptionSetFactory exceptionSetFactory =
classContext.getExceptionSetFactory(method);
// Perform type analysis using our special type merger
// (which handles String types specially, keeping track of
// which ones appear to be dynamically created)
RefComparisonTypeMerger typeMerger =
new RefComparisonTypeMerger(bugReporter, exceptionSetFactory);
TypeFrameModelingVisitor visitor =
new RefComparisonTypeFrameModelingVisitor(methodGen.getConstantPool(), bugReporter);
TypeAnalysis typeAnalysis =
new TypeAnalysis(methodGen, cfg, dfs, typeMerger, visitor, bugReporter, exceptionSetFactory);
TypeDataflow typeDataflow = new TypeDataflow(cfg, typeAnalysis);
typeDataflow.execute();
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
Instruction ins = location.getHandle().getInstruction();
short opcode = ins.getOpcode();
if (opcode == Constants.IF_ACMPEQ || opcode == Constants.IF_ACMPNE) {
checkRefComparison(location, jclass, methodGen, typeDataflow);
} else if (invokeInstanceSet.get(opcode)) {
InvokeInstruction inv = (InvokeInstruction) ins;
String methodName = inv.getMethodName(cpg);
String methodSig = inv.getSignature(cpg);
if ((methodName.equals("equals") && methodSig.equals("(Ljava/lang/Object;)Z"))
|| (methodName.equals("equalIgnoreCases") && methodSig.equals("(Ljava/lang/String;)Z"))) {
sawCallToEquals = true;
checkEqualsComparison(location, jclass, methodGen, typeDataflow);
}
}
}
// If a String reference comparison was found in the method,
// report it
if (stringComparison != null) {
if (sawCallToEquals &&
stringComparison.getPriority() >= NORMAL_PRIORITY) {
// System.out.println("Reducing priority of " + stringComparison);
stringComparison.setPriority(1 + stringComparison.getPriority());
}
if (stringComparison.getPriority() >= NORMAL_PRIORITY
&& !(method.isPublic() ||
method.isProtected())) {
// System.out.print("private/packed");
stringComparison.setPriority(1 + stringComparison.getPriority());
}
if (stringComparison.getPriority() <= LOW_PRIORITY) {
bugReporter.reportBug(stringComparison);
}
}
if (refComparison != null) {
if (false && sawCallToEquals) {
// System.out.println("Reducing priority of " + refComparison);
refComparison.setPriority(1 + refComparison.getPriority());
}
if (refComparison.getPriority() <= LOW_PRIORITY)
bugReporter.reportBug(refComparison);
}
}