3 Replies Latest reply on Apr 4, 2004 11:18 AM by Shigeru Chiba

    Can this be achieved using javassist?

    wangglei Newbie

      I had used javassist before for a simple profiler and I found it's very convenient to use. This timeI need to rewrite the bytecode in a more flexible way. One of the task is to change the the appearance of one class into another new class. That will include at least the following things:
      1. replace all "new Class1(...)" to "new Class2(....)" ;
      2. replace all the definition of "Class1 XXX" to "Class2 XXX": this will include field attributes,
      method signitures, and local variable types.

      The above seems pretty straight-forward to achieve in source-level, but now I need to do it at bytecode. So will Javasssit be able to achieve both of the above? Or either? I so far can't find a easy way to do it in Javassist. Or I may have missed some important fact of Javassist?

      Or do I have to use the javassist.bytecode package? If so, would it be better (in terms of both performance and programability) to use other low-level byte-code engineering tools like BCEL or ASM?