本文整理汇总了Java中org.apache.bcel.classfile.Method.isAbstract方法的典型用法代码示例。如果您正苦于以下问题:Java Method.isAbstract方法的具体用法?Java Method.isAbstract怎么用?Java Method.isAbstract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Method
的用法示例。
在下文中一共展示了Method.isAbstract方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
/**
* Test driver.
*/
public static void main(String[] argv) throws Exception {
if (argv.length != 1) {
System.err.println("Usage: " + BetterCFGBuilder2.class.getName() + " <class file>");
System.exit(1);
}
String methodName = System.getProperty("cfgbuilder.method");
JavaClass jclass = new ClassParser(argv[0]).parse();
ClassGen classGen = new ClassGen(jclass);
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.isAbstract() || method.isNative())
continue;
if (methodName != null && !method.getName().equals(methodName))
continue;
MethodGen methodGen = new MethodGen(method, jclass.getClassName(), classGen.getConstantPool());
CFGBuilder cfgBuilder = new BetterCFGBuilder2(methodGen);
cfgBuilder.build();
CFG cfg = cfgBuilder.getCFG();
CFGPrinter cfgPrinter = new CFGPrinter(cfg);
System.out.println("---------------------------------------------------------------------");
System.out.println("Method: " + SignatureConverter.convertMethodSignature(methodGen));
System.out.println("---------------------------------------------------------------------");
cfgPrinter.print(System.out);
}
}
示例2: visit
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void visit(Method obj) {
int accessFlags = obj.getAccessFlags();
if ((accessFlags & ACC_STATIC) != 0) return;
String name = obj.getName();
String sig = obj.getSignature();
if ((accessFlags & ACC_ABSTRACT) != 0) {
if (name.equals("equals")
&& sig.equals("(L" + getClassName() + ";)Z")) {
bugReporter.reportBug(new BugInstance(this, "EQ_ABSTRACT_SELF", LOW_PRIORITY).addClass(getDottedClassName()));
return;
} else if (name.equals("compareTo")
&& sig.equals("(L" + getClassName() + ";)I")) {
bugReporter.reportBug(new BugInstance(this, "CO_ABSTRACT_SELF", LOW_PRIORITY).addClass(getDottedClassName()));
return;
}
}
boolean sigIsObject = sig.equals("(Ljava/lang/Object;)Z");
if (name.equals("hashCode")
&& sig.equals("()I")) {
hasHashCode = true;
if (obj.isAbstract()) hashCodeIsAbstract = true;
// System.out.println("Found hashCode for " + betterClassName);
} else if (name.equals("equals")) {
if (sigIsObject) {
hasEqualsObject = true;
if (obj.isAbstract())
equalsObjectIsAbstract = true;
else {
Code code = obj.getCode();
byte[] codeBytes = code.getCode();
if ((codeBytes.length == 5 &&
(codeBytes[1] & 0xff) == INSTANCEOF)
|| (codeBytes.length == 15 &&
(codeBytes[1] & 0xff) == INSTANCEOF &&
(codeBytes[11] & 0xff) == INVOKESPECIAL)) {
equalsMethodIsInstanceOfEquals = true;
}
}
} else if (sig.equals("(L" + getClassName() + ";)Z"))
hasEqualsSelf = true;
} else if (name.equals("compareTo")) {
if (sig.equals("(Ljava/lang/Object;)I"))
hasCompareToObject = true;
else if (sig.equals("(L" + getClassName() + ";)I"))
hasCompareToSelf = true;
}
}
示例3: main
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public static void main(String[] argv) throws Exception {
if (argv.length != 1) {
System.err.println("Usage: " + DominatorsAnalysis.class.getName() + " <classfile>");
System.exit(1);
}
RepositoryLookupFailureCallback lookupFailureCallback = new RepositoryLookupFailureCallback() {
public void reportMissingClass(ClassNotFoundException ex) {
ex.printStackTrace();
System.exit(1);
}
};
AnalysisContext analysisContext = new AnalysisContext(lookupFailureCallback);
JavaClass jclass = new ClassParser(argv[0]).parse();
ClassContext classContext = analysisContext.getClassContext(jclass);
String methodName = System.getProperty("dominators.method");
boolean ignoreExceptionEdges = Boolean.getBoolean("dominators.ignoreExceptionEdges");
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.isNative() || method.isAbstract())
continue;
if (methodName != null && !methodName.equals(method.getName()))
continue;
System.out.println("Method: " + method.getName());
CFG cfg = classContext.getCFG(method);
DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
DominatorsAnalysis analysis = new DominatorsAnalysis(cfg, dfs, ignoreExceptionEdges);
Dataflow<BitSet, DominatorsAnalysis> dataflow =
new Dataflow<BitSet, DominatorsAnalysis>(cfg, analysis);
dataflow.execute();
for (Iterator<BasicBlock> j = cfg.blockIterator(); j.hasNext();) {
BasicBlock block = j.next();
BitSet dominators = analysis.getResultFact(block);
System.out.println("Block " + block.getId() + ": " + dominators);
}
}
}
示例4: main
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public static void main(String[] argv) throws Exception {
if (argv.length != 1) {
System.err.println("Usage: " + BlockTypeAnalysis.class.getName() + " <classfile>");
System.exit(1);
}
RepositoryLookupFailureCallback lookupFailureCallback = new RepositoryLookupFailureCallback() {
public void reportMissingClass(ClassNotFoundException ex) {
ex.printStackTrace();
System.exit(1);
}
};
AnalysisContext analysisContext = new AnalysisContext(lookupFailureCallback);
JavaClass jclass = new ClassParser(argv[0]).parse();
ClassContext classContext = analysisContext.getClassContext(jclass);
String methodName = System.getProperty("blocktype.method");
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.isNative() || method.isAbstract())
continue;
if (methodName != null && !methodName.equals(method.getName()))
continue;
System.out.println("Method: " + method.getName());
CFG cfg = classContext.getCFG(method);
DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
final BlockTypeAnalysis analysis = new BlockTypeAnalysis(dfs);
Dataflow<BlockType, BlockTypeAnalysis> dataflow =
new Dataflow<BlockType, BlockTypeAnalysis>(cfg, analysis);
dataflow.execute();
if (Boolean.getBoolean("blocktype.printcfg")) {
CFGPrinter cfgPrinter = new CFGPrinter(cfg) {
public String blockAnnotate(BasicBlock block) {
BlockType blockType = analysis.getResultFact(block);
return " [Block type: " + blockType.toString() + "]";
}
};
cfgPrinter.print(System.out);
}
}
}