Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a java classfile / bytecode editor to edit instructions? [closed]

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)

like image 603
MRalwasser Avatar asked Jul 22 '10 11:07

MRalwasser


People also ask

What is Java bytecode editor?

JBE is a bytecode editor suitable for viewing and modifying java class files. It is built on top of the open-source jclasslib bytecode viewer by ej-technologies. For verification and exporting the class files, JBE uses the the Bytecode Engineering Library by Apache's Jakarta project. JBE requires Java 1.5 to run.

Can you decompile Java bytecode?

Yes ,this is called as decompilation process to convert machine code or we can say it as byte code to its original source code but till some extent !

What is bytecode manipulation?

Bytecode is the instruction set of the Java Virtual Machine (JVM), and all languages that run on the JVM must eventually compile down to bytecode. Bytecode is manipulated for a variety of reasons: Program analysis: find bugs in your application.


2 Answers

I use reJ for editing class files directly.

It allows you to edit instructions, methods, constant pool, diff classes, and a split view with a hex editor.

It's ridiculously awesome.

like image 120
nahsra Avatar answered Sep 21 '22 18:09

nahsra


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.

like image 42
Thorbjørn Ravn Andersen Avatar answered Sep 18 '22 18:09

Thorbjørn Ravn Andersen