Storyyeller / Krakatau

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

Functions that only differ by return type result in compilation errors #50

Closed tbu- closed 8 years ago

tbu- commented 8 years ago

When decompiling the scala standard library to Java source files, things like this happen:

public static scala.collection.immutable.List empty()
{
    return scala.collection.immutable.List$.MODULE$.empty();
}
public static scala.collection.GenTraversable empty()
{
    return scala.collection.immutable.List$.MODULE$.empty();
}

This will not compile because the methods only differ by their return types.

From what I can tell this is supported by the bytecode because function calls contain the desired function signature, but not by the Java language.

Question: Is my interpretation of this correct?

Storyyeller commented 8 years ago

Yes.

This is one of many cases where bytecode can do something that can't be represented in Java source.

tbu- commented 8 years ago

Thanks for the answer. Could this be worked around by mangling the function names?

Storyyeller commented 8 years ago

It could, but it doesn't make sense to do that by default due to the obvious issues with reflection and inheritance. You could always add ad-hoc mangling if you want, though it's admittedly not so easy to extend right now. I was experimenting with a plugin system earlier but never got around to fleshing it out.