Is there any Java Decompiler that can correctly decompile calls to overloaded methods?

Posted by mihi on Stack Overflow See other posts from Stack Overflow or by mihi
Published on 2010-05-15T13:01:56Z Indexed on 2010/05/15 13:04 UTC
Read the original article Hit count: 322

Filed under:
|
|
|

Consider this (IMHO simple) example:

public class DecompilerTest {
    public static void main(String[] args) {
        Object s1 = "The", s2 = "answer";
        doPrint((Object) "You should know:");
        for (int i = 0; i < 2; i++) {
            doPrint(s1);
            doPrint(s2);
            s1 = "is";
            s2 = new Integer(42);
        }
        System.out.println();
    }

    private static void doPrint(String s1) {
        System.out.print("Wrong!");
    }

    private static void doPrint(Object s1) {
        System.out.print(s1 + " ");
    }
}

Compile it with source/target level 1.1 without debug information (i.e. no local variable information should be present) and try to decompile it. I tried Jad, JD-GUI and Fernflower, and all of them got at least one of the call wrong (i. e. the program printed "Wrong!" at least once)

Is there really no java decompiler that can infer the right casts so that it will not call the wrong overload?

© Stack Overflow or respective owner

Related posts about java

Related posts about decompiler