Reputation: 23551
When searching the web it is easy to find this way to print out Java bytecode:
http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/
What I could not find is if there is a standard representation of Java bytecode as a string and if there is a tool to compile string representation of Java bytecode into binary bytecode.
In .NET the equivalent tool is ilasm.exe. Is there something like this for Java and is it standard?
Upvotes: 2
Views: 3225
Reputation: 328556
There are tools to do this but they aren't part of the standard. You have two options:
Upvotes: 3
Reputation: 198023
If you're just trying to view the byte code of a .class
file, javap
is your friend.
There isn't really a "standard" way to convert Java bytecode to assembly -- since that's generally done only at runtime by the JIT -- but gcj
does something along those lines.
Upvotes: 1
Reputation: 718718
What I could not find is if there is a standard representation of Java bytecode as a string ...
There isn't one.
However, there are 3rd party tools for creating classfiles in a variety of ways. Bytecode asemblers like ASM or Jasmin are one approach, and another approach is to generate the bytecodes programatically using something like BCEL.
(The standard javap
utility can be told to output formatted bytecodes, but the format is not standardized, and there's no standard utility that goes in the other direction.)
Upvotes: 1