I found this question that answered it for C++:
How do you get assembler output from C/C++ source in gcc?
How do I check assembly output of Java code?
11.8k views Asked by Archishman Archi MAN Sravan Ku AtThere are 2 answers
Java uses both bytecode and assembly language machine code. It's a two-step process. The first step is to compile the Java source code to bytecode, as @elliott-frisch pointed out. At runtime, the JVM watches which parts of the program are used a lot. If a method "runs hot", it's compiled to machine code. That, in turn, is a multi-step process itself, including many optimizations and replacing fast code with even faster code. I've described this in BeyondJava.net several years ago.
If you can spare 45 minutes, I also recommend watching the talk of Charles Nutter. "Down the rabbit hole" is a great introduction to how Java compiles to assembly language.
As for your question: you have to add some parameters to the command starting the application:
javaw.exe -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly Adder
You also have to download a special DLL and store it in the jre folder. Also see Chris Newlands article on how to compile this file for OS X.
Java uses bytecode. The most similar would be
javap
, per the linked Oracle documentation, the javap command disassembles one or more class files. Its output depends on the options used.If I compile that to
Main.class
and then runjavap -v Main.class
I get