views:

235

answers:

2

Is there a utility (or eclipse plugin) for editing java class files? I'd like to manipulate the bytecode of a java class file without recompiling it nor having a complete buildpath.

E.g. to rename methods, add/delete instructions, change constants etc.

The only utilities I found are:

  • classeditor but it's very limited in functionality (e.g. renaming of things and manipulating instructions isn't possible).

  • jbe doesn't save changes (maybe because class verifying fails - before I made any changes, although the class runs perfectly)

    (jbe initially had a classpath issue, adding the class path to the jbe.bat file helped)

+1  A: 

I have not seen any byte code -> byte code frontends, but plenty backends.

I would suggest that you have a look at the many byte code manipulation libraries like javassist which allow loading byte code, manipulate it, and save it back to disk, and then write a small main that does exactly that.

Thorbjørn Ravn Andersen
+1  A: 

Find this list of byte code manipulation/code generation libraries helpful?

Guy Sensei
I need working tools, I don't have the time to code such a tool by myself (neither with the help of those libraries).
MRalwasser