Storyyeller / Krakatau

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

Issue with Enum #36

Closed henkelis closed 10 years ago

henkelis commented 10 years ago

Hi,

I'm getting an issue with decompiling an enum - the decompiler creates a values method that contains a name that is not dereferenced, hence it will not recompile (example below, non-dereferenced field is '[Lstatus.Status;').

public static status.Status[] values()
{
    return (status.Status[])(([Lstatus.Status;)(Object)$VALUES).clone();
}

In each case I've come across the name starts with a [.

I've traced the code and can see that the name contains the (potentially) erroneous character on returning from get_cp_raw, but I don't know how to fix it.

I have a simple test class the produces the error, but can't work out how to attach it here :o|

I'm compiling with JAVA 1.7.

Mark.

ysangkok commented 10 years ago

Could you please make the class file available on a file hosting service, e.g. https://hushfile.it/ ?

henkelis commented 10 years ago

Sure. Source: https://hushfile.it/539e150ab0617#_xSlfEcIqT0JYlSMMWJowqz_rsZBRx-QqDk584uj Compiled: https://hushfile.it/539e15a3ecaef#ThWmyfTy1ta2ahvVedicdLLYK-xswUf4nquIQcbD

Storyyeller commented 10 years ago

It is not always possible to generate recompileable code and not always desirable to do so even when possible.

The philosophy of Krakatau is to produce recompileable code when it is feasible to do so and try to produce reasonably readable output otherwise. Furthermore, supporting enums is not a priority because they are syntactic sugar and unlikely to survive obfuscation.

If your goal is to get compileable code and the target is not obfuscated, I recommend using a traditional decompiler like Procyon instead.

That being said, this error looks like it should be easy to fix, so I will look into it.

henkelis commented 10 years ago

Ok, thanks.

On 16/06/14 04:34, Storyyeller wrote:

It is not always possible to generate compileable code and not always desirable to do so even when possible https://gist.github.com/Storyyeller/78e116f7357e0641e22d.

The philosophy of Krakatau is to produce compileable code when it is feasible to do so and try to produce reasonably readable output otherwise.

Furthermore, supporting enums are not a priority because they are syntactic sugar and unlikely to survive obfuscation.

If your goal is to get compileable code and the target is not obfuscated, I recommend using a traditional decompiler like Procyon https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler instead.

— Reply to this email directly or view it on GitHub https://github.com/Storyyeller/Krakatau/issues/36#issuecomment-46138610.

Storyyeller commented 10 years ago

Fixed in commit 673cf34acde58b9f0e671979a8cf558a70668ff4

Interestingly, I discovered another bug in the process of fixing this one.