本文整理汇总了Java中org.apache.bcel.generic.INVOKEVIRTUAL.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java INVOKEVIRTUAL.getSignature方法的具体用法?Java INVOKEVIRTUAL.getSignature怎么用?Java INVOKEVIRTUAL.getSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.INVOKEVIRTUAL
的用法示例。
在下文中一共展示了INVOKEVIRTUAL.getSignature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isStringAppend
import org.apache.bcel.generic.INVOKEVIRTUAL; //导入方法依赖的package包/类
private boolean isStringAppend(Instruction ins, ConstantPoolGen cpg) {
if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) ins;
if (invoke.getMethodName(cpg).equals("append") && invoke.getClassName(cpg).startsWith("java.lang.StringB")) {
String sig = invoke.getSignature(cpg);
char firstChar = sig.charAt(1);
return firstChar == '[' || firstChar == 'L';
}
}
return false;
}
示例2: analyzeMethod
import org.apache.bcel.generic.INVOKEVIRTUAL; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
MethodGen methodGen = classContext.getMethodGen(method);
if (methodGen == null)
return;
ConstantPoolGen cpg = methodGen.getConstantPool();
CFG cfg = classContext.getCFG(method);
ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
LockDataflow dataflow = classContext.getLockDataflow(method);
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof INVOKEVIRTUAL))
continue;
INVOKEVIRTUAL inv = (INVOKEVIRTUAL) ins;
String methodName = inv.getName(cpg);
String methodSig = inv.getSignature(cpg);
if (Hierarchy.isMonitorWait(methodName, methodSig) || Hierarchy.isMonitorNotify(methodName, methodSig)) {
int numConsumed = inv.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE)
throw new DataflowAnalysisException("Unpredictable stack consumption", methodGen, handle);
ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location);
if (!frame.isValid())
// Probably dead code
continue;
if (frame.getStackDepth() - numConsumed < 0)
throw new DataflowAnalysisException("Stack underflow", methodGen, handle);
ValueNumber ref = frame.getValue(frame.getNumSlots() - numConsumed);
LockSet lockSet = dataflow.getFactAtLocation(location);
int lockCount = lockSet.getLockCount(ref.getNumber());
if (lockCount == 0) {
Collection<ValueNumber> lockedValueNumbers = lockSet.getLockedValueNumbers(frame);
boolean foundMatch = false;
for (ValueNumber v : lockedValueNumbers)
if (frame.veryFuzzyMatch(ref, v)) {
foundMatch = true;
break;
}
if (!foundMatch) {
String type = methodName.equals("wait") ? "MWN_MISMATCHED_WAIT" : "MWN_MISMATCHED_NOTIFY";
String sourceFile = classContext.getJavaClass().getSourceFileName();
// Report as medium priority only if the method is
// public.
// Non-public methods may be properly locked in a
// calling context.
int priority = method.isPublic() ? NORMAL_PRIORITY : LOW_PRIORITY;
bugAccumulator.accumulateBug(
new BugInstance(this, type, priority).addClassAndMethod(methodGen, sourceFile),
SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, handle));
}
}
}
}
bugAccumulator.reportAccumulatedBugs();
}