tags:

views:

103

answers:

4

Using javap I can disassemble a java class into byte code. If I want to run this byte code, or a modified version of it, how do I do it? Please spare me the "don't bother" answers as I am doing this for educational reasons. I've googled and looked at other Stack Overflow questions but couldn't find an answer.

+1  A: 

Use ClassLoader.defineClass() along with a custom classloader. The Javadoc page provides an example of almost exactly what you want to do.

Greg Hewgill
+5  A: 

Perhaps Jasmin is what you are looking for.

Ville Krumlinde
A: 

Perhaps Jakarta BCEL might be of interest?

teabot
A: 

You can use a java dis-assembler to produce java code you can compile (perhaps with some fixing of the code by hand)

You can then modify the code and re-compile it.

Peter Lawrey