20-Feb-16 javap
Bytecode Java is compiled into bytecode, which is intermediate between Java and a “real” assembly language To implement Java, it is only necessary to implement bytecode, and this is a lot simpler Because Java is now so widespread, many other languages now can be compiled to bytecode Ada, Smalltalk, Lisp, Python (Jython), Ruby (JRuby), undoubtedly others Java’s javap command shows the generated bytecode
Example % javac JavapDemoApplication.java % javap -c JavapDemoApplication Compiled from JavapDemoApplication.java public class JavapDemoApplication extends java.lang.Object { public JavapDemoApplication(); public static void main(java.lang.String[]); } Method JavapDemoApplication() 0 aload_0 1 invokespecial #1 4 return Method void main(java.lang.String[]) 0 getstatic #2 3 ldc #3 5 invokevirtual #4 8 return Source:
Writing in bytecode Unfortunately, javap doesn’t show you the complete bytecode, only the “interesting” bits It is possible to write and run bytecode programs, using a bytecode assembler called Jasmin Unfortunately, Jasmin is old, not maintained, and hard to find I have a Jasmin plugin for Eclipse, written by a pair of former students, but it’s not “ready for prime time”
The End