本文整理汇总了Java中org.apache.bcel.classfile.Method.isSynchronized方法的典型用法代码示例。如果您正苦于以下问题:Java Method.isSynchronized方法的具体用法?Java Method.isSynchronized怎么用?Java Method.isSynchronized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Method
的用法示例。
在下文中一共展示了Method.isSynchronized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scan
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
/**
* Scan a method for self call sites.
*
* @param node the CallGraphNode for the method to be scanned
*/
private void scan(CallGraphNode node) throws CFGBuilderException {
Method method = node.getMethod();
CFG cfg = classContext.getCFG(method);
if (method.isSynchronized())
hasSynchronization = true;
Iterator<BasicBlock> i = cfg.blockIterator();
while (i.hasNext()) {
BasicBlock block = i.next();
Iterator<InstructionHandle> j = block.instructionIterator();
while (j.hasNext()) {
InstructionHandle handle = j.next();
Instruction ins = handle.getInstruction();
if (ins instanceof InvokeInstruction) {
InvokeInstruction inv = (InvokeInstruction) ins;
Method called = isSelfCall(inv);
if (called != null) {
// Add edge to call graph
CallSite callSite = new CallSite(method, block, handle);
callGraph.createEdge(node, callGraph.getNodeForMethod(called), callSite);
// Add to called method set
calledMethodSet.add(called);
}
} else if (ins instanceof MONITORENTER || ins instanceof MONITOREXIT) {
hasSynchronization = true;
}
}
}
}
示例2: prescreen
import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public boolean prescreen(Method method, ClassContext classContext) {
BitSet bytecodeSet = classContext.getBytecodeSet(method);
// The pattern requires a get/put pair accessing the same field.
if (!(bytecodeSet.get(Constants.GETSTATIC) && bytecodeSet.get(Constants.PUTSTATIC)) &&
!(bytecodeSet.get(Constants.GETFIELD) && bytecodeSet.get(Constants.PUTFIELD)))
return false;
// If the method is synchronized, then we'll assume that
// things are properly synchronized
if (method.isSynchronized())
return false;
return true;
}