I am aware that when decompiling a jar file, it is normal for the resulting .java files to contain syntax errors, but I am unsure of why and worse off I am sometimes unsure of how to fix these syntax errors. Take int[] arrayOfInt = new int['€'];
, for example. Eclipse complains that '€'
does not belong. Surprise! I know this already, but why does this happen. How can I find out what this value should be?

- 191
- 2
- 9
-
You should try out these decompilers all powered by procyon 1, 2, 3. – 0xec Nov 05 '14 at 04:16
3 Answers
The reason it happens is because JD-Gui isn't encoding unicode properly. You can see that the thing inside the quotes is two bytes, and appears to be interpreted as nonstandard upper 128 characters. I.e. JD-Gui is emitting unicode, but the charset isn't declared correctly so your editor interprets it as two raw bytes in an 8bit charset instead of a single unicode character.
One solution is to use a Decompiler that emits unicode escapes instead of raw unicode byte sequences. That way, any editor will be able to view it correctly. I'd recommend Procyon (it's a lot better than JD-Gui anyway).

- 2,012
- 11
- 16
-
"raw unicode byte sequences" -> "raw UTF8 byte sequences". Only probably though, because the sequence translates to
C2 80
, or0x80
translated back to Unicode, which is not a regular Unicode character at all. (It might just mean the value0x80
but in that case the original decompiler really screwed things up.) – Jongware Nov 05 '14 at 10:51 -
I didn't notice that. In that case, it's probably screwed up escaping of null characters (which have to be escaped specially in classfiles, but obviously not in source code). – Antimony Nov 05 '14 at 16:09
-
Thanks for the advice. Does Procyon also make obfuscated code easier to handle? The code that I am dealing with has obviously been tampered with, as it has variable names such as
str1
,str2
,str3
, etc. – DaveTheMinion Nov 05 '14 at 22:24 -
For highly obfuscated code, Krakatau is the best. But if you're code is obfuscated, you can pretty much give up on getting a compileable result. – Antimony Nov 06 '14 at 05:28
-
Thank you for the advice. By using Procyon, I was able to decompile the jar file into it's
.java
code files. Unlike JD-GUI's generated.java
files, the ones created by Procyon only contained a single syntax error in one of the classes which was easily corrected. It would also appear that the jar file was not obfuscated, but JD-GUI's poor job at decompiling mangled the code so much that it appeared as though it had been messed with. – DaveTheMinion Nov 08 '14 at 20:55
You should use Luyten. It is a java decompiler just like JD-Gui, but it lacks much of the bugs inside jd-gui logic.
It is a front-end to Procyon.
PS: Sorry, I know i should commenting on Antimony's answer, but i don't have the necessary points to do that.

- 198
- 1
- 3
-
1I've found that Luyten often lags behind the most recent version of Procyon, so I have to rebuild manually. – Antimony Nov 06 '14 at 05:28
Try taking a look at Bytecode Viewer - https://github.com/Konloch/bytecode-viewer
It allows you to select from 3 different Java decompilers. It can also display the Bytecode and Hexcode of the Class file you select. (And more, check it out)

- 21
- 1
- 2