javassist.expr
package). Instances of this class specifies how to instrument of the bytecodes representing a method body. They are passed to CtClass.instrument()
or CtMethod.instrument()
as a parameter.
Example:
ClassPool cp = ClassPool.getDefault(); CtClass point = cp.get("Point"); CtClass singleton = cp.get("Singleton"); CtClass client = cp.get("Client"); CodeConverter conv = new CodeConverter(); conv.replaceNew(point, singleton, "makePoint"); client.instrument(conv);
This program substitutes "Singleton.makePoint()
" for all occurrences of "new Point()
" appearing in methods declared in a Client
class.
@see javassist.CtClass#instrument(CodeConverter)
@see javassist.CtMethod#instrument(CodeConverter)
@see javassist.expr.ExprEditor
|
|