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


Java CodeAttribute.setMaxStack方法代码示例

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


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

示例1: insertAuxInitializer

import scouter.javassist.bytecode.CodeAttribute; //导入方法依赖的package包/类
private static void insertAuxInitializer(CodeAttribute codeAttr,
                                         Bytecode initializer,
                                         int stacksize)
    throws BadBytecode
{
    CodeIterator it = codeAttr.iterator();
    int index = it.skipSuperConstructor();
    if (index < 0) {
        index = it.skipThisConstructor();
        if (index >= 0)
            return;         // this() is called.

        // Neither this() or super() is called.
    }

    int pos = it.insertEx(initializer.get());
    it.insert(initializer.getExceptionTable(), pos);
    int maxstack = codeAttr.getMaxStack();
    if (maxstack < stacksize)
        codeAttr.setMaxStack(stacksize);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:22,代码来源:CtClassType.java

示例2: runEditor

import scouter.javassist.bytecode.CodeAttribute; //导入方法依赖的package包/类
protected void runEditor(ExprEditor ed, CodeIterator oldIterator)
    throws CannotCompileException
{
    CodeAttribute codeAttr = oldIterator.get();
    int orgLocals = codeAttr.getMaxLocals();
    int orgStack = codeAttr.getMaxStack();
    int newLocals = locals();
    codeAttr.setMaxStack(stack());
    codeAttr.setMaxLocals(newLocals);
    ExprEditor.LoopContext context
        = new ExprEditor.LoopContext(newLocals);
    int size = oldIterator.getCodeLength();
    int endPos = oldIterator.lookAhead();
    oldIterator.move(currentPos);
    if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos))
        edited = true;

    oldIterator.move(endPos + oldIterator.getCodeLength() - size);
    codeAttr.setMaxLocals(orgLocals);
    codeAttr.setMaxStack(orgStack);
    maxLocals = context.maxLocals;
    maxStack += context.maxStack;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:24,代码来源:Expr.java

示例3: transform

import scouter.javassist.bytecode.CodeAttribute; //导入方法依赖的package包/类
public int transform(CtClass tclazz, int pos, CodeIterator iterator,
                     ConstPool cp) throws BadBytecode
{
    int c = iterator.byteAt(pos);
    if (c == PUTFIELD || c == PUTSTATIC) {
        int index = iterator.u16bitAt(pos + 1);
        String typedesc = isField(tclazz.getClassPool(), cp,
                            fieldClass, fieldname, isPrivate, index);
        if (typedesc != null) {
            if (c == PUTSTATIC) {
                CodeAttribute ca = iterator.get();
                iterator.move(pos);
                char c0 = typedesc.charAt(0);
                if (c0 == 'J' || c0 == 'D') {       // long or double
                    // insertGap() may insert 4 bytes.
                    pos = iterator.insertGap(3);
                    iterator.writeByte(ACONST_NULL, pos);
                    iterator.writeByte(DUP_X2, pos + 1);
                    iterator.writeByte(POP, pos + 2);
                    ca.setMaxStack(ca.getMaxStack() + 2);
                }
                else {
                    // insertGap() may insert 4 bytes.
                    pos = iterator.insertGap(2);
                    iterator.writeByte(ACONST_NULL, pos);
                    iterator.writeByte(SWAP, pos + 1);
                    ca.setMaxStack(ca.getMaxStack() + 1);
                }

                pos = iterator.next();
            }

            int mi = cp.addClassInfo(methodClassname);
            String type = "(Ljava/lang/Object;" + typedesc + ")V";
            int methodref = cp.addMethodrefInfo(mi, methodName, type);
            iterator.writeByte(INVOKESTATIC, pos);
            iterator.write16bit(methodref, pos + 1);
        }
    }

    return pos;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:43,代码来源:TransformWriteField.java

示例4: doit

import scouter.javassist.bytecode.CodeAttribute; //导入方法依赖的package包/类
/**
 * Performs code conversion.
 */
protected void doit(CtClass clazz, MethodInfo minfo, ConstPool cp)
    throws CannotCompileException
{
   Transformer t;
    CodeAttribute codeAttr = minfo.getCodeAttribute();
    if (codeAttr == null || transformers == null)
        return;
    for (t = transformers; t != null; t = t.getNext())
        t.initialize(cp, clazz, minfo);

    CodeIterator iterator = codeAttr.iterator();
    while (iterator.hasNext()) {
        try {
            int pos = iterator.next();
            for (t = transformers; t != null; t = t.getNext())
                pos = t.transform(clazz, pos, iterator, cp);
        }
        catch (BadBytecode e) {
            throw new CannotCompileException(e);
        }
    }

    int locals = 0;
    int stack = 0;
    for (t = transformers; t != null; t = t.getNext()) {
        int s = t.extraLocals();
        if (s > locals)
            locals = s;

        s = t.extraStack();
        if (s > stack)
            stack = s;
    }

    for (t = transformers; t != null; t = t.getNext())
        t.clean();

    if (locals > 0)
        codeAttr.setMaxLocals(codeAttr.getMaxLocals() + locals);

    if (stack > 0)
        codeAttr.setMaxStack(codeAttr.getMaxStack() + stack);

    try {
    	minfo.rebuildStackMapIf6(clazz.getClassPool(),
                                 clazz.getClassFile2());
    }
    catch (BadBytecode b) {
        throw new CannotCompileException(b.getMessage(), b);
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:55,代码来源:CodeConverter.java

示例5: doit

import scouter.javassist.bytecode.CodeAttribute; //导入方法依赖的package包/类
/**
 * Undocumented method.  Do not use; internal-use only.
 */
public boolean doit(CtClass clazz, MethodInfo minfo)
    throws CannotCompileException
{
    CodeAttribute codeAttr = minfo.getCodeAttribute();
    if (codeAttr == null)
        return false;

    CodeIterator iterator = codeAttr.iterator();
    boolean edited = false;
    LoopContext context = new LoopContext(codeAttr.getMaxLocals());

    while (iterator.hasNext())
        if (loopBody(iterator, clazz, minfo, context))
            edited = true;

    ExceptionTable et = codeAttr.getExceptionTable();
    int n = et.size();
    for (int i = 0; i < n; ++i) {
        Handler h = new Handler(et, i, iterator, clazz, minfo);
        edit(h);
        if (h.edited()) {
            edited = true;
            context.updateMax(h.locals(), h.stack());
        }
    }

    // codeAttr might be modified by other partiess
    // so I check the current value of max-locals.
    if (codeAttr.getMaxLocals() < context.maxLocals)
        codeAttr.setMaxLocals(context.maxLocals);

    codeAttr.setMaxStack(codeAttr.getMaxStack() + context.maxStack);
    try {
        if (edited)
            minfo.rebuildStackMapIf6(clazz.getClassPool(),
                                     clazz.getClassFile2());
    }
    catch (BadBytecode b) {
        throw new CannotCompileException(b.getMessage(), b);
    }

    return edited;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:47,代码来源:ExprEditor.java


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