Archive for November, 2014


On the quality of decompiled code

I have a piece of advice on the Minecraft code that I always wanted to say but never had the opportunity/context to: The decompiled code, as produced by MCP, jd-gui or any other decompiler, does not reflect Mojang’s actual coding.

I remember the days when people complained “Notch y u no use case!!!111” when he actually did. Garry from GMod made a blog post on that, but it was lost to time.

What happens is that, since they’re functionally equal, the Java compiler produces the same bytecode for a case as it would for a regular if-else. With that, a decompiler sees any case statement as a simple if-else, because that’s how it was compiled.

Decompilers are never 100% accurate. When MCP switched from jad to Fernflower, the amount of patches required for the Minecraft code to compile may have been cut down massively, but it will never reach the same level as Mojang’s original code.

Sidebar: I still remember the days I fixed trivial MiscPeripherals bugs by poking at the bytecode with JBE (and oftentimes fail to), since a full round of “start Eclipse -> fix bug -> recompile -> reobfuscate -> test in Minecraft” took 15-20 minutes on my aging PC…