Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.97k stars 220 forks source link

Can't do assignments before calling "this" or "super" #15

Closed ysangkok closed 11 years ago

ysangkok commented 11 years ago

Original code:

class Test {
    Test() {
        this(new Object());
    }
    Test(Object i) {
    }
}

Decompiled:

class Test {
    Test()
    {
        Object a = new Object();
        this(a);
    }

    Test(Object a)
    {
        super();
    }
}

Trying to compile:

 % javac Test.java 
Test.java:5: error: call to this must be first statement in constructor
        this(a);
            ^
1 error
Storyyeller commented 11 years ago

This is a known issue. Unfortunately, the limitations of Java mean that some patterns of bytecode can't reasonably be decompiled into valid Java. In these cases Krakatau will resort to pseduocode.