当前位置: 首页>>代码示例>>Java>>正文


Java InstructionHandle.getNext方法代码示例

本文整理汇总了Java中org.apache.bcel.generic.InstructionHandle.getNext方法的典型用法代码示例。如果您正苦于以下问题:Java InstructionHandle.getNext方法的具体用法?Java InstructionHandle.getNext怎么用?Java InstructionHandle.getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.generic.InstructionHandle的用法示例。


在下文中一共展示了InstructionHandle.getNext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkIntegrity

import org.apache.bcel.generic.InstructionHandle; //导入方法依赖的package包/类
public void checkIntegrity() {
	// Ensure that basic blocks have only consecutive instructions
	for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) {
		BasicBlock basicBlock = i.next();
		InstructionHandle prev = null;
		for (Iterator<InstructionHandle> j = basicBlock.instructionIterator(); j.hasNext();) {
			InstructionHandle handle = j.next();
			if (prev != null && prev.getNext() != handle)
				throw new IllegalStateException("Non-consecutive instructions in block " + basicBlock.getId() +
				        ": prev=" + prev + ", handle=" + handle);
			prev = handle;
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:CFG.java

示例2: getSuccessorOf

import org.apache.bcel.generic.InstructionHandle; //导入方法依赖的package包/类
/**
 * Get the successor of given instruction within the basic block.
 * @param handle the instruction
 * @return the instruction's successor, or null if the instruction
 *         is the last in the basic block
 */
public InstructionHandle getSuccessorOf(InstructionHandle handle) {
	if (VERIFY_INTEGRITY) {
		if (!containsInstruction(handle))
			throw new IllegalStateException();
	}
	return handle == lastInstruction
		? null
		: handle.getNext();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:BasicBlock.java

示例3: getCookieInstructionLocation

import org.apache.bcel.generic.InstructionHandle; //导入方法依赖的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;
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:54,代码来源:CookieFlagsDetector.java

示例4: build

import org.apache.bcel.generic.InstructionHandle; //导入方法依赖的package包/类
/**
 * Build the line number information.
 * Should be called before any other methods.
 */
public void build() {
	int numGood = 0, numBytecodes = 0;

	if (DEBUG) {
		System.out.println("Method: " + methodGen.getName() + " - " + methodGen.getSignature() +
		        "in class " + methodGen.getClassName());
	}

	// Associate line number information with each InstructionHandle
	LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());

	if (table != null && table.getTableLength() > 0) {
		checkTable(table);
		InstructionHandle handle = methodGen.getInstructionList().getStart();
		while (handle != null) {
			int bytecodeOffset = handle.getPosition();
			if (bytecodeOffset < 0)
				throw new IllegalStateException("Bad bytecode offset: " + bytecodeOffset);
			if (DEBUG) System.out.println("Looking for source line for bytecode offset " + bytecodeOffset);
			int sourceLine;
			try {
				sourceLine = table.getSourceLine(bytecodeOffset);
			} catch (ArrayIndexOutOfBoundsException e) {
				if (LINE_NUMBER_BUG)
					throw e;
				else
					sourceLine = -1;
			}
			if (sourceLine >= 0)
				++numGood;
			lineNumberMap.put(handle,
			        new LineNumber(bytecodeOffset, sourceLine));
			handle = handle.getNext();
			++numBytecodes;
		}
		hasLineNumbers = true;

		if (DEBUG) System.out.println("\t" + numGood + "/" + numBytecodes + " had valid line numbers");
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:45,代码来源:LineNumberMap.java


注:本文中的org.apache.bcel.generic.InstructionHandle.getNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。