1 Reply Latest reply on Jul 6, 2004 12:01 PM by chiba

    Modify codes ???

    ericmacau

      Hello,

      I am a beginner in using Javaassist.

      Is it possible to modify the variable values and variable name with Javassist ?

      For example,

      class test {
      public void init(int a, String x) {
      int i;
      String o;

      i = a + 1;
      o = x + " ... ";
      }
      }


      In the above java, after I compiled it to test.class, how can I change the

      1. init(int a, String x) to init(int intVar, String strVar)
      2. int i ----> int tmpVar;
      3. String o ----> String oVar;
      4. i = a + 1 ----> i = 10;



      Best regards,
      Eric

        • 1. Re: Modify codes ???
          chiba

          You should look at javassist.bytecode.LocalVariableAttribute
          for renaming variable names.
          (Please read the tutorial to know how to
          obtain that object.)
          Renaming local variable names does not make
          any sense after compilation, though.

          As for the number 4, unfortunately, Javassist does not support it.