本文整理汇总了Java中edu.umd.cs.findbugs.classfile.engine.bcel.UnpackedBytecodeCallback类的典型用法代码示例。如果您正苦于以下问题:Java UnpackedBytecodeCallback类的具体用法?Java UnpackedBytecodeCallback怎么用?Java UnpackedBytecodeCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnpackedBytecodeCallback类属于edu.umd.cs.findbugs.classfile.engine.bcel包,在下文中一共展示了UnpackedBytecodeCallback类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBytecodeSet
import edu.umd.cs.findbugs.classfile.engine.bcel.UnpackedBytecodeCallback; //导入依赖的package包/类
/**
* Get a BitSet representing the bytecodes that are used in the given
* method. This is useful for prescreening a method for the existence of
* particular instructions. Because this step doesn't require building a
* MethodGen, it is very fast and memory-efficient. It may allow a Detector
* to avoid some very expensive analysis, which is a Big Win for the user.
*
* @param method
* the method
* @return the BitSet containing the opcodes which appear in the method, or
* null if the method has no code
*/
@CheckForNull
static public BitSet getBytecodeSet(JavaClass clazz, Method method) {
XMethod xmethod = XFactory.createXMethod(clazz, method);
if (cachedBitsets().containsKey(xmethod)) {
return cachedBitsets().get(xmethod);
}
Code code = method.getCode();
if (code == null)
return null;
byte[] instructionList = code.getCode();
// Create callback
UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);
// Scan the method.
BytecodeScanner scanner = new BytecodeScanner();
scanner.scan(instructionList, callback);
UnpackedCode unpackedCode = callback.getUnpackedCode();
BitSet result = null;
if (unpackedCode != null)
result = unpackedCode.getBytecodeSet();
cachedBitsets().put(xmethod, result);
return result;
}
示例2: getBytecodeSet
import edu.umd.cs.findbugs.classfile.engine.bcel.UnpackedBytecodeCallback; //导入依赖的package包/类
/**
* Get a BitSet representing the bytecodes that are used in the given
* method. This is useful for prescreening a method for the existence of
* particular instructions. Because this step doesn't require building a
* MethodGen, it is very fast and memory-efficient. It may allow a Detector
* to avoid some very expensive analysis, which is a Big Win for the user.
*
* @param method
* the method
* @return the BitSet containing the opcodes which appear in the method, or
* null if the method has no code
*/
@CheckForNull
static public BitSet getBytecodeSet(JavaClass clazz, Method method) {
XMethod xmethod = XFactory.createXMethod(clazz, method);
if (cachedBitsets().containsKey(xmethod)) {
return cachedBitsets().get(xmethod);
}
Code code = method.getCode();
if (code == null)
return null;
byte[] instructionList = code.getCode();
// Create callback
UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);
// Scan the method.
BytecodeScanner scanner = new BytecodeScanner();
scanner.scan(instructionList, callback);
UnpackedCode unpackedCode = callback.getUnpackedCode();
BitSet result = null;
if (unpackedCode != null)
result = unpackedCode.getBytecodeSet();
cachedBitsets().put(xmethod, result);
return result;
}