New Java Decompiler Written in C Promises 10x Speed Boost But Faces Memory Management Concerns

BigGo Editorial Team
New Java Decompiler Written in C Promises 10x Speed Boost But Faces Memory Management Concerns

A new Java decompiler called garlic-decompiler has emerged, written entirely in C and claiming significant performance improvements over traditional Java-based tools. The project aims to convert compiled Java bytecode back into readable source code, supporting .class files, JAR archives, and WAR files.

Supported File Types:

  • .class files (Java bytecode)
  • .jar files (Java archives)
  • .war files (Web application archives)
  • .dex files (planned, currently unsupported)

Performance Claims vs Reality Check

The developer claims garlic-decompiler runs about 10 times faster than Java-based alternatives while using fewer system resources. The compiled binary weighs in at just 300KB, making it remarkably lightweight. However, early testing by community members reveals some growing pains typical of C programs dealing with complex data structures.

One user reported a segmentation fault while processing a JAR file with multiple threads enabled, highlighting the challenges of memory management in C when handling Java bytecode parsing. The developer responded quickly, requesting the problematic file to fix the issue.

Performance Claims:

  • 10x faster than Java-based decompilers
  • Lower resource usage than Java alternatives
  • Multi-threaded processing support (default: 4 threads)

Memory Management Challenges Surface

Technical discussions in the community have focused on the project's memory management approach. The decompiler uses a custom string library and implements separate memory pools for multi-threaded operations, with a global pool for single-threaded mode.

However, experienced developers have identified potential issues where the code mixes static strings with heap-allocated strings inconsistently. This creates situations where calling functions cannot properly determine whether returned memory should be freed, potentially leading to memory leaks or crashes.

Development Approach and Future Plans

The project represents a largely manual effort, with the developer stating it was 90% by hand, 10% AI - a ratio that many in the community view as ideal for learning-focused projects. The motivation appears to be both educational and practical, aimed at understanding JVM internals while creating a faster tool.

I am writing the part of decompiling dex and apk. The current speed is about 10 times faster than that of Java, and it takes up less resources than Java.

Future development includes planned support for Android DEX files, though this feature remains unimplemented. The project also includes a javap-like mode for faster bytecode analysis, with LineNumber and StackMapTable attributes disabled for improved performance.

Build Requirements:

  • cmake >= 3.26
  • No other dependencies
  • Compiled binary size: ~300KB

Conclusion

While garlic-decompiler shows promise with its speed claims and lightweight design, it faces the typical challenges of C programs handling complex parsing tasks. The active developer response to bug reports and the educational nature of the project suggest it could mature into a viable alternative to existing Java decompilers, provided the memory management issues are resolved. For now, users should expect some rough edges typical of early-stage C projects dealing with intricate bytecode analysis.

Reference: garlic-decompiler