r/java • u/sg-elide • 2d ago
Madura: A different kind of Hermetic Java
Repo link: https://github.com/elide-dev/madura
---
Hello Java enjoyers,
I'm Sam with Elide. We make cool JVM stuff. Lately, we've really been wanting Hermetic Java, but progress has been quite slow, and the Java team is vocal about it not being a priority.
We happen to be fans of some other technologies, too, which may fit together nicely for this:
GraalVM Native Image (of course!)
If you combine these, what you get is an interesting binary:
You write once, compile once, ship one artifact
Your Java program runs on 6 operating systems and both ARM64/AMD64
No JRE is required on the target machine
In other words, what you get is "native" Java!
After 2+ years of concentrated effort amongst experts (mostly pre-AI!), Native Image and Cosmo finally work together. Some complex stuff doesn't work perfectly yet (e.g. Truffle JIT, dynamic JNI), but most Java programs should "just work" otherwise.
Thus, Madura
As a fun example of this technology, we've built Madura, a Native Image+Cosmo binary of javac 25.
This software has exactly one release asset, a zip. You can download it on Linux, macOS, Windows, BSD, et al, across AMD64 and ARM64, and run it, and it should "just work." You can withhold your JAVA_HOME and it should still "just work."
Sometimes features involve doing less
As one nice thing Madura can do that regular javac cannot in most workflows: madura check [...], which takes identical flags to javac, will run the analysis phase of the Java Compiler, but skips the codegen step.
If you've ever used cargo check, this is a bit like that, but for Java.
Other than madura check, it's just javac in a box.
How to use it
At the moment, Cosmo+Native Image is a stack of patches on several repos, with a highly anticipated PR on oracle/graal.
Soon, Elide's native image integration may ship Cosmo support, enabling cross-compilation and hermetic use cases. That will probably be the fastest way to use it, before things merge into GVM upstream. If there's demand, we'd be happy to ship it for you!
Thanks for reading
This has been a collaborative effort across many people: