views:

15689

answers:

8

On Java performance questions on this site I often see responses from people who have "decompiled" the Java class file to see how the compiler optimizes certain things.

What program can I use to decompile a class file? Does you actually get Java code, or is it just JVM assembly code?

Thanks!

A: 

Take a look at cavaj.

Paulo Guedes
That also uses `jad` underneath.
Quinn Taylor
+11  A: 

To see Java source code check some decompiler. Go search for jad.

If you want to see bytecodes, just use javap which comes with the JDK.

Dev er dev
+7  A: 

There's a few decompilers out there... a quick search yields:

  1. JAD
  2. DJ Java Decompiler
  3. Mocha

and many more.

These produce Java code. Java comes with something that lets you see JVM byte code (javap).

Bill James
+2  A: 

There's a few programs you can use. You will get the actual Java code. Sometimes the code will have been obfuscated so method are called one letter or number or a random mix of letters and numbers.

DJ Decompiler Mocha

Mike Pone
+5  A: 

I use JAD Decompiler.

There is a eclipse plugin to it. pretty nice: jadeclipse

sakana
+3  A: 

Most decompilers for Java are based on JAD. It's a great tool, but unfortunately hasn't been updated for a while and does not handle Java 1.5+ classes very well. I have not seen any tools that will properly handle 1.5+ classes.

John Meagher
here you go: I just posted an answer to your answer ;) JDK1.5 and more supported!
VonC
thanks for the info. I've never found that one when searching for newer decompilers. I'll have to try it out.
John Meagher
+46  A: 
VonC
Thanks for pointing this one out... it looks like a nice project, and we have needed one with solid 1.5 support for a long time.
jsight
+1 It's worth mentioning that it's also modularized, so the core (implemented in C++) can be leveraged elsewhere.
Quinn Taylor
+1 for Java Decompiler! I was stuck with JAD for a long time, although it works well.
Thimmayya
+2  A: 

Soot is an option for newer Java code. At least it has the advantage of still being recently maintained...

Also, Java Decompiler is a decompiler with both a stand-alone GUI and Eclipse integration.

Lastly, Jdec hasn't been mentioned, though it's not as polished as other options.

Quinn Taylor