Storyyeller / Krakatau

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

Missing throws declaration. #38

Closed JojOatXGME closed 10 years ago

JojOatXGME commented 10 years ago

Some methods throws throwables (like excaptions) or call other methods which throws throwables. This methods have to catch them or must have a "throws-declaration".

For example

public void test() {
    throw new Exception();
}

is not a valid method but the decompiler produce methods like that. I think the method should look like this:

public void test() throws Exception {
    throw new Exception();
}
Storyyeller commented 10 years ago

Unfortunately, this is a limitation of the Java language that is not shared by bytecode, so in general, it is not possible to make the decompiled source follow this.

JojOatXGME commented 10 years ago

Yes but it make the produced sources incompilable. If the decompiler checks whether there is a possible unhandled throwable, it would be very helpful.

I don't know how your decompiler works but I think If there would be a (not too difficult) way to implement that, you should think about that. If you don't have enough information to decide it yet, I understand that you don't want to parse the sources or bytecode again only to get this information.

(My english is not very well and I hope you can read it without problems. The comment should not attack you. I just wanted to say my opinion. If you as a developer have a different opinion, I accept it also.)

Storyyeller commented 10 years ago

No decompiler in existence will always produce recompileable code, even for unobfuscated Java. That being said, Procyon tends to do a pretty good job if that's your goal.

The primary goal of Krakatau is to assist reverse engineering of obfuscated Java, so recompilation is not a major concern.