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


Java CodeIterator.next方法代码示例

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


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

示例1: transformInvokevirtualsIntoPutAndGetfields

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile) throws CannotCompileException, BadBytecode {
	for ( Object o : classfile.getMethods() ) {
		final MethodInfo methodInfo = (MethodInfo) o;
		final String methodName = methodInfo.getName();
		if ( methodName.startsWith( EACH_READ_METHOD_PREFIX )
				|| methodName.startsWith( EACH_WRITE_METHOD_PREFIX )
				|| methodName.equals( GETFIELDHANDLER_METHOD_NAME )
				|| methodName.equals( SETFIELDHANDLER_METHOD_NAME ) ) {
			continue;
		}

		final CodeAttribute codeAttr = methodInfo.getCodeAttribute();
		if ( codeAttr == null ) {
			continue;
		}

		final CodeIterator iter = codeAttr.iterator();
		while ( iter.hasNext() ) {
			int pos = iter.next();
			pos = transformInvokevirtualsIntoGetfields( classfile, iter, pos );
			transformInvokevirtualsIntoPutfields( classfile, iter, pos );
		}
		final StackMapTable smt = MapMaker.make( classPool, methodInfo );
		codeAttr.setAttribute( smt );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:FieldTransformer.java

示例2: scan

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private void scan(int pos, CodeIterator iter, Subroutine sub) throws BadBytecode {
    // Skip already processed blocks
    if (done.contains(Integer.valueOf(pos)))
        return;

    done.add(Integer.valueOf(pos));

    int old = iter.lookAhead();
    iter.move(pos);

    boolean next;
    do {
        pos = iter.next();
        next = scanOp(pos, iter, sub) && iter.hasNext();
    } while (next);

    iter.move(old);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:19,代码来源:SubroutineScanner.java

示例3: getBehaviourBytecode

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
/**
 * This is basically the InstructionPrinter.getMethodBytecode but with a
 * CtBehaviour parameter instead of a CtMethod
 * 
 * @param behavior
 * @return
 */
public static String getBehaviourBytecode(CtBehavior behavior) {
    MethodInfo info = behavior.getMethodInfo2();
    CodeAttribute code = info.getCodeAttribute();
    if (code == null) {
        return "";
    }

    ConstPool pool = info.getConstPool();
    StringBuilder sb = new StringBuilder(1024);

    CodeIterator iterator = code.iterator();
    while (iterator.hasNext()) {
        int pos;
        try {
            pos = iterator.next();
        } catch (BadBytecode e) {
            throw new JVoidIntrumentationException("BadBytecoode", e);
        }

        sb.append(pos + ": " + InstructionPrinter.instructionString(iterator, pos, pool) + "\n");
    }
    return sb.toString();
}
 
开发者ID:jVoid,项目名称:jVoid,代码行数:31,代码来源:JavassistUtils.java

示例4: scan

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private void scan(int pos, CodeIterator iter, Subroutine sub) throws BadBytecode {
    // Skip already processed blocks
    if (done.contains(new Integer(pos)))
        return;

    done.add(new Integer(pos));

    int old = iter.lookAhead();
    iter.move(pos);

    boolean next;
    do {
        pos = iter.next();
        next = scanOp(pos, iter, sub) && iter.hasNext();
    } while (next);

    iter.move(old);
}
 
开发者ID:MeRPG2,项目名称:EndHQ-Libraries,代码行数:19,代码来源:SubroutineScanner.java

示例5: initialize

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
public void initialize(ConstPool cp, CtClass clazz, MethodInfo minfo) throws CannotCompileException {
    /*
     * This transformer must be isolated from other transformers, since some
     * of them affect the local variable and stack maximums without updating
     * the code attribute to reflect the changes. This screws up the
     * data-flow analyzer, since it relies on consistent code state. Even
     * if the attribute values were updated correctly, we would have to
     * detect it, and redo analysis, which is not cheap. Instead, we are
     * better off doing all changes in initialize() before everyone else has
     * a chance to muck things up.
     */
    CodeIterator iterator = minfo.getCodeAttribute().iterator();
    while (iterator.hasNext()) {
        try {
            int pos = iterator.next();
            int c = iterator.byteAt(pos);

            if (c == AALOAD)
                initFrames(clazz, minfo);

            if (c == AALOAD || c == BALOAD || c == CALOAD || c == DALOAD
                    || c == FALOAD || c == IALOAD || c == LALOAD
                    || c == SALOAD) {
                pos = replace(cp, iterator, pos, c, getLoadReplacementSignature(c));
            } else if (c == AASTORE || c == BASTORE || c == CASTORE
                    || c == DASTORE || c == FASTORE || c == IASTORE
                    || c == LASTORE || c == SASTORE) {
                pos = replace(cp, iterator, pos, c, getStoreReplacementSignature(c));
            }

        } catch (Exception e) {
            throw new CannotCompileException(e);
        }
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:36,代码来源:TransformAccessArrayField.java

示例6: transformInvokevirtualsIntoPutAndGetfields

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile)
		throws CannotCompileException {
	List methods = classfile.getMethods();
	for (Iterator method_iter = methods.iterator(); method_iter.hasNext();) {
		MethodInfo minfo = (MethodInfo) method_iter.next();
		String methodName = minfo.getName();
		if (methodName.startsWith(EACH_READ_METHOD_PREFIX)
		    || methodName.startsWith(EACH_WRITE_METHOD_PREFIX)
		    || methodName.equals(GETFIELDHANDLER_METHOD_NAME)
		    || methodName.equals(SETFIELDHANDLER_METHOD_NAME)) {
			continue;
		}
		CodeAttribute codeAttr = minfo.getCodeAttribute();
		if (codeAttr == null) {
			return;
		}
		CodeIterator iter = codeAttr.iterator();
		while (iter.hasNext()) {
			try {
				int pos = iter.next();
				pos = transformInvokevirtualsIntoGetfields(classfile, iter,
				                                           pos);
				pos = transformInvokevirtualsIntoPutfields(classfile, iter,
				                                           pos);

			} catch (BadBytecode e) {
				throw new CannotCompileException(e);
			}
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:32,代码来源:FieldTransformer.java

示例7: analyzeNextEntry

import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private void analyzeNextEntry(MethodInfo method, CodeIterator iter,
        IntQueue queue, Executor executor) throws BadBytecode {
    int pos = queue.take();
    iter.move(pos);
    iter.next();

    Frame frame = frames[pos].copy();
    Subroutine subroutine = subroutines[pos];

    try {
        executor.execute(method, pos, iter, frame, subroutine);
    } catch (RuntimeException e) {
        throw new BadBytecode(e.getMessage() + "[pos = " + pos + "]", e);
    }

    int opcode = iter.byteAt(pos);

    if (opcode == TABLESWITCH) {
        mergeTableSwitch(queue, pos, iter, frame);
    } else if (opcode == LOOKUPSWITCH) {
        mergeLookupSwitch(queue, pos, iter, frame);
    } else if (opcode == RET) {
        mergeRet(queue, iter, pos, frame, subroutine);
    } else if (Util.isJumpInstruction(opcode)) {
        int target = Util.getJumpTarget(pos, iter);

        if (Util.isJsr(opcode)) {
            // Merge the state before the jsr into the next instruction
            mergeJsr(queue, frames[pos], subroutines[target], pos, lookAhead(iter, pos));
        } else if (! Util.isGoto(opcode)) {
            merge(queue, frame, lookAhead(iter, pos));
        }

        merge(queue, frame, target);
    } else if (opcode != ATHROW && ! Util.isReturn(opcode)) {
        // Can advance to next instruction
        merge(queue, frame, lookAhead(iter, pos));
    }

    // Merge all exceptions that are reachable from this instruction.
    // The redundancy is intentional, since the state must be based
    // on the current instruction frame.
    mergeExceptionHandlers(queue, method, pos, frame);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:45,代码来源:Analyzer.java


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