Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choose and test java decompiler [closed]

Now I'm trying to find the best java decompiler, I found these:

  • http://java.decompiler.free.fr/
  • http://www.reversed-java.com/fernflower/
  • http://dj.navexpress.com/
  • http://cavaj-java-decompiler.en.softonic.com/

With these decompilers I handle byte code of this class:

public class ss { public static void main(String args[]) {   try{    System.out.println("try");    }   catch(Exception e)   {    System.out.println("catch");   }   finally   {System.out.println("finally");} } } 

and I got the following results:

fernflower:

public class ss {     public static void main(String[] var0) {       try {          System.out.println("try");       } catch (Exception var5) {          System.out.println("catch");       } finally {          System.out.println("finally");       }     } } 

DJ Java Decompiler:

import java.io.PrintStream;  public class ss {      public ss()     {     }      public static void main(String args[])     {         System.out.println("try");         System.out.println("finally");         break MISSING_BLOCK_LABEL_50;         Exception exception;         exception;         System.out.println("catch");         System.out.println("finally");         break MISSING_BLOCK_LABEL_50;         Exception exception1;         exception1;         System.out.println("finally");         throw exception1;     } } 

cavaj:

import java.io.PrintStream;  public class ss {      public ss()     {     }      public static void main(String args[])     {         System.out.println("try");         System.out.println("finally");         break MISSING_BLOCK_LABEL_50;         Exception exception;         exception;         System.out.println("catch");         System.out.println("finally");         break MISSING_BLOCK_LABEL_50;         Exception exception1;         exception1;         System.out.println("finally");         throw exception1;     } } 

http://java.decompiler.free.fr/:

import java.io.PrintStream; public class ss {   public static void main(String[] paramArrayOfString)   {     try     {       System.out.println("try");     }     catch (Exception localException)     {       System.out.println("catch");     }     finally {       System.out.println("finally");     }   } } 

I see that the best result in decompiler: http://java.decompiler.free.fr/

To test, I wrote very simple code. What do you think, what code to write to test decompilers? Maybe the idea is to better than a try{} catch(){} finally{}?

like image 362
user471011 Avatar asked Oct 09 '10 23:10

user471011


2 Answers

The code that you use to test should test the features available the in JDK used to compile the target class. For example, if you know that your target is written in Java 1.5, it is reasonable to assume that the code might include generics, so you will want to make sure that your chosen decompiler handles them properly. In my experience, the freely available decompilers tend to lag behind the JDK releases in terms of the features they support by 1-2 releases.

Based on personal trial and error, JD tends to do the best job in general. However, if you're decompiling code that was written in 1.3 or lower, I'd also suggest you give JODE a try.

EDIT, 5 years later:

CFR, Procyon, and Fernflower lead the way in this space.

like image 175
Justin Garrick Avatar answered Sep 26 '22 02:09

Justin Garrick


Procyon has it's own comparison.

like image 28
Janus Troelsen Avatar answered Sep 25 '22 02:09

Janus Troelsen