Storyyeller / Krakatau

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

Duplicate methods #39

Closed JojOatXGME closed 9 years ago

JojOatXGME commented 9 years ago

Sometimes your decompiler produce the same method multiple times. This happens if a class A inherits from B (directly or indirectly) and overwrites the method f but the return-type of f in A is more specific as in B.

I'm not sure if that's always happens but I have several occurrences.

For example your decompiler produce something like that:

public class SpecialACreator implements ACreator
{
    public SpecialA createA()
    {
        return new SpecialA();
    }

    public A createA()
    {
        return (A)(Object)this.createA();
    }
}

The solution would be to write only the first function (with more specific return-type or from more specific class) to the sources.

Storyyeller commented 9 years ago

If Krakatau produces multiple methods, that means the class being decompiled has multiple methods.

Most likely, you're seeing methods that were autogenerated by the compiler. Krakatau does very little resugaring, unlike most other decompilers, since it adds enormous complexity and is useless for obfuscated code anyway.