tags:

views:

1181

answers:

9

Is there a nice place for learning the JVM bytecode instruction set. The specification perhaps and maybe some tutorials?

I ask because I would like to design a toy language and a compiler for it that generates JVM bytecode.

Thanks for your knowledge and perhaps googling.

+3  A: 

First Google hit for "Java bytecode specification": http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html. See chapter 4, "The class file format" and chapter 6, "The Java Virtual Machine Instruction Set".

Adam Rosenfield
+2  A: 

Also useful are the javap disassembler and bytecode manipulation frameworks like ASM and BCEL, even if all you want to do is verify your classes.

McDowell
+4  A: 

A little more "graphic" explanation.

http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/

OscarRyz
A: 

This is a bit more specialized, but here is an on-line presentation on how to optimize generated bytecode for running on the JVM. It was presented at the recent JVM Languages Summit conferences. InfoQ has a collection of presentations from that conference which might be of help to someone wanting to bring up a language on the JVM (or to see what's already been done).

joel.neely
+2  A: 

The book Programming for the Java Virtual Machine explains the JVM instruction set and how to write code for it. It also introduces a bytecode assembler called Oolong, which I have not been able to download. You can, however, use Jasmin, the predecessor of Oolong. Essentially, you write a text file with instructions and Jasmin will spit out a .class file. The book was published in 1999, but it is still a good and gentle introduction to the VM.

Bala
A: 

Some resources I found useful when started to learn about JVM bytecode (Sorry for the self reference).

http://bytecoded.blogspot.com/2009/01/continuing-with-learning-path-good.html

Maxim Veksler
+1  A: 

To start with, I suggest generating Java code from your language.

This will make reading and debugging much simpler.

Peter Lawrey
+1  A: 

The VM spec is here.

The updated for chapter 4 are here. The updates cover new attributes added since the 2nd edition was made.

TofuBeer
+1  A: 

Perhaps check out Preon's example on how to parse a Java class file. It has a fairly complete representation of the bytecode in a Java object model.

Wilfred Springer