tags:

views:

377

answers:

3

For CIL / MSIL, I can write the code in a text editor and compile / decompile with ilasm / ildasm.

I can use Reflector to see the CIL generated by a .NET class.

In the Java world, javap -c shows the disassembled byte code.

How do I compile Java bytecode? (i.e. the Java equivalent of ilasm / ildasm).

Is there an IDE that supports Java bytecode?

Does the IDE support debugging i.e. single stepping / breakpoints etc.?

+2  A: 

Bytecode Outline plugin for Eclipse

to play with bytecode you can use ASM or BCEL

Take a look at org.apache.bcel.util.BCELifier, it takes a given class and converts it to a BCEL program (in Java, of course). It will show you how certain code is generated using BCEL.

01
A: 

The JVM heavily optimised the byte code at runtime, so there are not the same advantages to writing and even reading the byte code for a developer. The byte code is for a virtual machine and it does give you much indication as to how the machine will actually perform the operations at runt time. i.e. you will get just as much information reading the source.

In most cases the source is available and if you want to read the code whent he source is not available I suggest using a decompiler.

The main use for byte code is to manipulate the code either at build time or on the fly to add code to the start or end of methods for example.

Peter Lawrey
It appears to me that the questioner quite understands the usage of bytecode.
codekaizen
+1  A: 

Jasmin:

http://jasmin.sourceforge.net/

It's an assembler for Java bytecode. While an above poster pointed out that hand-coding Java bytecode may not be very useful, Jasmin has been used as a backend for compilers targeting the JVM as a runtime. Thus, your compiler can output Jasmin assembler instructions and then Jasmin converts them into Java classes.

Nate