本文整理汇总了Java中org.apache.bcel.generic.INVOKEVIRTUAL.getMethodName方法的典型用法代码示例。如果您正苦于以下问题:Java INVOKEVIRTUAL.getMethodName方法的具体用法?Java INVOKEVIRTUAL.getMethodName怎么用?Java INVOKEVIRTUAL.getMethodName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.INVOKEVIRTUAL
的用法示例。
在下文中一共展示了INVOKEVIRTUAL.getMethodName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preScreen
import org.apache.bcel.generic.INVOKEVIRTUAL; //导入方法依赖的package包/类
public boolean preScreen(MethodGen mg) {
ConstantPoolGen cpg = mg.getConstantPool();
int lockCount = mg.isSynchronized() ? 1 : 0;
boolean sawWaitOrNotify = false;
InstructionHandle handle = mg.getInstructionList().getStart();
while (handle != null && !(lockCount >= 2 && sawWaitOrNotify)) {
Instruction ins = handle.getInstruction();
if (ins instanceof MONITORENTER)
++lockCount;
else if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL inv = (INVOKEVIRTUAL) ins;
String methodName = inv.getMethodName(cpg);
if (methodName.equals("wait") || methodName.startsWith("notify"))
sawWaitOrNotify = true;
}
handle = handle.getNext();
}
return lockCount >= 2 && sawWaitOrNotify;
}
示例2: getCookieInstructionLocation
import org.apache.bcel.generic.INVOKEVIRTUAL; //导入方法依赖的package包/类
/**
* This method is used to track calls made on a specific object. For instance, this could be used to track if "setHttpOnly(true)"
* was executed on a specific cookie object.
*
* This allows the detector to find interchanged calls like this
*
* Cookie cookie1 = new Cookie("f", "foo"); <- This cookie is unsafe
* Cookie cookie2 = new Cookie("b", "bar"); <- This cookie is safe
* cookie1.setHttpOnly(false);
* cookie2.setHttpOnly(true);
*
* @param cpg ConstantPoolGen
* @param startLocation The Location of the cookie initialization call.
* @param objectStackLocation The index of the cookie on the stack.
* @param invokeInstruction The instruction we want to detect.s
* @return The location of the invoke instruction provided for the cookie at a specific index on the stack.
*/
private Location getCookieInstructionLocation(ConstantPoolGen cpg, Location startLocation, int objectStackLocation, String invokeInstruction) {
Location location = startLocation;
InstructionHandle handle = location.getHandle();
int loadedStackValue = 0;
// Loop until we find the setSecure call for this cookie
while (handle.getNext() != null) {
handle = handle.getNext();
Instruction nextInst = handle.getInstruction();
// We check if the index of the cookie used for this invoke is the same as the one provided
if (nextInst instanceof ALOAD) {
ALOAD loadInst = (ALOAD)nextInst;
loadedStackValue = loadInst.getIndex();
}
if (nextInst instanceof INVOKEVIRTUAL
&& loadedStackValue == objectStackLocation) {
INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) nextInst;
String methodNameWithSignature = invoke.getClassName(cpg) + "." + invoke.getMethodName(cpg);
if (methodNameWithSignature.equals(invokeInstruction)) {
Integer val = ByteCode.getConstantInt(handle.getPrev());
if (val != null && val == TRUE_INT_VALUE) {
return new Location(handle, location.getBasicBlock());
}
}
}
}
return null;
}