3 Replies Latest reply on May 9, 2004 12:11 PM by chiba

    Does Javassist really support the parameter variables $1 $2

    jclee49

      Hi,
      I am trying to write a wrapper for the instrumented methods and print out the parameters ($1, $2 .... according to the javassist manual). The following is an extract of my code:

      CtMethod mnew = CtNewMethod.copy(mold, methodName, clazz, null);
      StringBuffer body = new StringBuffer();
      :
      body.append(nname + "($$);\n");
      :
      body.append("{ System.out.println($1); }");
      mnew.setBody(body.toString());
      clazz.addMethod(mnew);


      And I am getting the following javassist compiling error, any clues out there. I am using version 2.6.

      javassist.CannotCompileException: [source error] no such field: $1
      at javassist.CtBehavior.setBody(CtBehavior.java:163)
      at javassist.CtMethod.setBody(CtMethod.java:311)


      Any info will be appreciated.

      John