Hacker News new | ask | show | jobs
by nunobrito 269 days ago
Can the decompiled result be compiled again?
2 comments

It's not a perfect decompiler, some obfuscated code gets decompiled into commented-out bytecode.

However, most of the time it'll output perfectly valid Java code that'll compile if you just create the necessary maven/ant/gradle build configuration to get all of the sources loaded correctly.

I've actually had this fix a bug before. An O(n^2) issue adding a character at time to a string inside a loop.

I had decompiled the class, fixed the issue, checked in the original decompiled source and then the change. Then a coworker pointed out that the original decompiled source also fixed the issue.

After a bit of digging, I learned that hotspot compiler had code to detect and fix the issue, but it was looking for the pattern generated by a modern compiler, and the library was compiled with an older compiler.

(It's been a while, but I think it was the JAI library, and the issue was triggered by long comments in a PNG.)