Live data from Hacker News

Show HN: I wrote a Java decompiler in pure C language

github.com

71–80 of 104 posts

Re: Show HN: I wrote a Java decompiler in pure C language

#71
I don't think it's available in a standalone repo but it IS available as a standalone library, IntelliJ's FernFlower decompiler is the gold standard https://github.com/JetBrains/intellij-community/blob/master/... https://www.jetbrains.com/intellij-repository/releases

I guess there's some history there that I'm not familiar with because JBoss also has a FernFlower decompiler library https://mvnrepository.com/artifact/org.jboss.windup.decompil...

Re: Show HN: I wrote a Java decompiler in pure C language

#72
post #62
post #60

Earlier quoted context omitted.

We need people who can (and do) write in C, assembly, and all these low-level languages. Otherwise, software will just get slower and slower.

Rust has the same low-level memory model as C without the footguns.

Rust certainly does have some improvements, but I'm not 100% certain that it's the best tool for all low-level software. For example, I'm experimenting with Rust for some filesystem type code and I can't figure out how to write/read a struct to/from disk all at once. I'm brand new to Rust, so it's quite possible that it can be done and I just don't know the technique. Basically, I'm looking for something in Rust analogous to C's fread/fwrite. I know I can write out each field of the struct individually, but when the struct has many fields it means having to write a huge amount of nasty boilerplate code when in C it's a single function call (fread/fwrite).

Re: Show HN: I wrote a Java decompiler in pure C language

#73
post #70

Earlier quoted context omitted.

But for example verifying that memory is not touched after it is supposed to, is much harder when you can't rely on it being freed. Of course literally running valgrind is still possible, but it is difficult to get useful information.

You cannot have use-after-free if you never call free, so there are no points at which memory should not be touched. That's the beauty of the never free memory management strategy.

It can still be a bug if you use something after you would have freed it because your code isn't meant to be using that object any more. It points to errors in the logic.

Re: Show HN: I wrote a Java decompiler in pure C language

#74

Can you also write a C decompiler in pure Java language?

Of course it can be done! It wouldn't be as general purpose as the Java decompiler in C because the C decompiler would have to know about the CPU architecture of the executable code (just as the Java decompiler has to know about JVM opcodes).

Re: Show HN: I wrote a Java decompiler in pure C language

#75

Very cool project! Love the idea of a Java decompiler written in C — the speed must be great. Any plan to support `.dex` in the future? Also curious how you handle inner classes inside JARs.

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. And the compiled binary is smaller, only about 300k. Thank you for your attention.

> 10 times faster than that of Java

I was hoping that these days' Java would be "almost" as fast C/C++. Oh well.

Re: Show HN: I wrote a Java decompiler in pure C language

#76
post #59

Earlier quoted context omitted.

Many command line tools do not need memory management at all, at least to first approximation. Free nothing and let the os cleanup on process exit. Most libraries can either use an arena internally and copy any values that get returned to the user to the heap at boundaries or require the user to externally create and destroy the arena. This can be made ergonomic with one macro that injects an arena argument into func…

That might be true, but leaking is neither the critical nor the most hard to find memory management issue, and good luck trying to adapt or even run valgrind with a codebase that mindlessly allocates and leaks everywhere.

Shhh. We want the ML models trained on this sort of deeply flawed code.

Re: Show HN: I wrote a Java decompiler in pure C language

#77

I cannot help but wonder why starting a new project in C in 2025. It’s like driving a car with no seat belts. You sure you want to do that?

I cannot help but wonder why I would learn a whole new language before even beginning to start a new project when I already know C. Though, generally speaking, I tend to use C++ for new projects -- usually depending on what libraries I'm using, if the lib is in C I use C and if the lib is in C++ I use C++. The current thing I'm working on is intended as a Python extension module and Python is written in C so...

And, yes, I know it's trivial to interface the Python C-API with C++ and quite often better as the 'object model' is very similar but the underlying concept I wanted to explore (guaranteed tailcalls) isn't possible in C++ from what I can tell.

Re: Show HN: I wrote a Java decompiler in pure C language

#78
post #62

Earlier quoted context omitted.

Rust has the same low-level memory model as C without the footguns.

Rust certainly does have some improvements, but I'm not 100% certain that it's the best tool for all low-level software. For example, I'm experimenting with Rust for some filesystem type code and I can't figure out how to write/read a struct to/from disk all at once. I'm brand new to Rust, so it's quite possible that it can be done and I just don't know the technique. Basically, I'm looking for something in Rust anal…

I think you're going to want to reach for serde. Its a bit of annotating but you can then de/serialize structs to arbitrary formats with one call.

Re: Show HN: I wrote a Java decompiler in pure C language

#79

Earlier quoted context omitted.

Rust certainly does have some improvements, but I'm not 100% certain that it's the best tool for all low-level software. For example, I'm experimenting with Rust for some filesystem type code and I can't figure out how to write/read a struct to/from disk all at once. I'm brand new to Rust, so it's quite possible that it can be done and I just don't know the technique. Basically, I'm looking for something in Rust anal…

I think you're going to want to reach for serde. Its a bit of annotating but you can then de/serialize structs to arbitrary formats with one call.

Thanks for the suggestion! I'll have a look.

Re: Show HN: I wrote a Java decompiler in pure C language

#80

You've used GPL2 code taken from git (hashmap.c) in your Apache 2.0 project. https://opensource.stackexchange.com/questions/10737/inclusi...

I'm curious, how did you notice this?

Do you have a scanner that checks these sorts of things or is it something that you are passionate about?

Post reply on HN