本文整理汇总了Java中org.apache.bcel.generic.ALOAD.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ALOAD.getIndex方法的具体用法?Java ALOAD.getIndex怎么用?Java ALOAD.getIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.ALOAD
的用法示例。
在下文中一共展示了ALOAD.getIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCookieInstructionLocation
import org.apache.bcel.generic.ALOAD; //导入方法依赖的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;
}
示例2: indexToCheckForAlias
import org.apache.bcel.generic.ALOAD; //导入方法依赖的package包/类
private int indexToCheckForAlias(InstructionHandle ih, MethodGen mg) {
if (mg.isArrayStore(ih.getInstruction()) || ih.getInstruction() instanceof PUTFIELD) {
ih = mg.getObjectReferenceLoadInstruction(ih);
ALOAD objectLoadInstruction = (ALOAD) ih.getInstruction();
// The 'not an ALOAD' case is already dealt with.
return objectLoadInstruction.getIndex();
}
return -1;
}
示例3: visitALOAD
import org.apache.bcel.generic.ALOAD; //导入方法依赖的package包/类
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
public void visitALOAD(ALOAD o){
int idx = o.getIndex();
if (idx < 0){
constraintViolated(o, "Index '"+idx+"' must be non-negative.");
}
else{
int maxminus1 = max_locals()-1;
if (idx > maxminus1){
constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
}
}
}