Hello,
I have tried the following code, based on the tutorial:
=================================================
public class Test {
public static void main(String[] args) throws Exception {
ClassPool pool = ClassPool.getDefault();
pool.insertClassPath("some-path");
CtClass cc = pool.get("nl.vu.cs.iids.MyPoint");
CtMethod sMethod = cc.getDeclaredMethod("setTest1");
sMethod.instrument(new ExprEditor() {
public void edit(MethodCall m) throws
CannotCompileException {
System.out.println("========> " + m.getMethodName() +
" line: " + m.getLineNumber());
m.replace("{}");
//m.replace("{ $1 = 0; newX = $1 + 50.2; $_ =
$proceed($$); System.out.println(\"This is added line.\"); }");
}
});
}
}
===============================================
when I run the program I get the following error:
========> toString line: 28
javassist.CannotCompileException: the resulting value is not stored in $_
at javassist.expr.Expr.checkResultValue(Expr.java:170)
at javassist.expr.MethodCall.replace(MethodCall.java:209)
at nl.vu.cs.iids.Test$1.edit(Test.java:32)
at javassist.expr.ExprEditor.doit(ExprEditor.java:118)
at javassist.CtBehavior.instrument(CtBehavior.java:362)
at nl.vu.cs.iids.Test.main(Test.java:29)
Exception in thread "main"
===============================================
As I know, when we want to remove a method-call expression we can just give the
"{}" source text to the replace method. Am I right?
Thanks in advance
Reza
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3857302#3857302
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3857302
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user