Storyyeller / Krakatau

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

Recover variable names #167

Closed KOLANICH closed 4 years ago

KOLANICH commented 4 years ago

https://ci.appveyor.com/api/buildjobs/gtyiueue5u7joyiv/artifacts/compiler%2Fjvm%2Ftarget%2Fwindows%2Fkaitai-struct-compiler.msi (unpack it for example with lessmsi, contains a bunch of jars inside)

io/kaitaistruct/RuntimeConfig$.java

cfr:

@Override
public RuntimeConfig apply(boolean autoRead, boolean readStoresPos, boolean opaqueTypes, CppRuntimeConfig cppConfig, String goPackage, String javaPackage, String javaFromFileClass, String dotNetNamespace, String phpNamespace, String pythonPackage) {
    return new RuntimeConfig(autoRead, readStoresPos, opaqueTypes, cppConfig, goPackage, javaPackage, javaFromFileClass, dotNetNamespace, phpNamespace, pythonPackage);
}

krakatau:

public io.kaitai.struct.RuntimeConfig apply(boolean b, boolean b0, boolean b1, io.kaitai.struct.CppRuntimeConfig a, String s, String s0, String s1, String s2, String s3, String s4) {
    return new io.kaitai.struct.RuntimeConfig(b, b0, b1, a, s, s0, s1, s2, s3, s4);
}
Storyyeller commented 4 years ago

Krakatau is designed to handle obfuscated code, and thus it doesn't trust optional debug metadata.

KOLANICH commented 4 years ago

Glad to hear that it targets obfuscated code. Anyway, sometimes I have to decompile nonobfuscated sources, but just not in Java, just to get the picture what is going on. So it may be useful to have this feature switcheable.

Janmm14 commented 4 years ago

You can use another decompiler for such a case. Fernflower, CFR, Procyon (Luyten) are respecting such debug information.

KOLANICH commented 4 years ago

CFR, Procyon (including Luyten) and JD-GUI fail in decompiling Scala code. CFR fails hard in the sense that decompilation is stopped on an error. Luyten and JD-GUI fail more softly - only some classes are not decompiled. About Fernflower .... I haven't used it, definitely should try. So currently Krakatau is the bsst decompiler for Java I know. It has some drawbacks like it cannot decompile lambdas, but it can decompile the classes on which all other decompilers I used had failed.