public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
@Override public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List<MethodInfo> methods = cf.getMethods(); for (MethodInfo minfo: methods.toArray(new MethodInfo[methods.size()])) editor.doit(this, minfo); }
/** * Modifies the method/constructor body. * * <p>While executing this method, only <code>replace()</code> * in <code>Expr</code> is available for bytecode modification. * Other methods such as <code>insertBefore()</code> may collapse * the bytecode because the <code>ExprEditor</code> loses * its current position. * * @param editor specifies how to modify. * @see javassist.expr.Expr#replace(String) * @see #insertBefore(String) */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
/** * Modifies the method/constructor body. * * <p>While executing this method, only <code>replace()</code> * in <code>Expr</code> is available for bytecode modification. * Other methods such as <code>insertBefore()</code> may collapse * the bytecode because the <code>ExprEditor</code> loses * its current position. * * @param editor specifies how to modify. * @see javassist.expr.Expr#replace(String) * @see #insertBefore(String) */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
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; } }
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; } }
public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
/** * Modifies the method/constructor body. * * @param editor specifies how to modify. */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
/** * Modifies the method/constructor body. * * @param editor specifies how to modify. */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
/** * Modifies the method/constructor body. * * <p>While executing this method, only <code>replace()</code> * in <code>Expr</code> is available for bytecode modification. * Other methods such as <code>insertBefore()</code> may collapse * the bytecode because the <code>ExprEditor</code> loses * its current position. * * @param editor specifies how to modify. * @see javassist.expr.Expr#replace(String) * @see #insertBefore(String) */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
/** * Modifies the method/constructor body. * * <p>While executing this method, only <code>replace()</code> * in <code>Expr</code> is available for bytecode modification. * Other methods such as <code>insertBefore()</code> may collapse * the bytecode because the <code>ExprEditor</code> loses * its current position. * * @param editor specifies how to modify. * @see javassist.expr.Expr#replace(String) * @see #insertBefore(String) */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
/** * Modifies the method/constructor body. * * <p>While executing this method, only <code>replace()</code> * in <code>Expr</code> is available for bytecode modification. * Other methods such as <code>insertBefore()</code> may collapse * the bytecode because the <code>ExprEditor</code> loses * its current position. * * @param editor specifies how to modify. * @see javassist.expr.Expr#replace(String) * @see #insertBefore(String) */ public void instrument(ExprEditor editor) throws CannotCompileException { // if the class is not frozen, // does not turn the modified flag on. if (declaringClass.isFrozen()) declaringClass.checkModify(); if (editor.doit(declaringClass, methodInfo)) declaringClass.checkModify(); }
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; } }
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; } }
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; } }
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; } }