Meet unzstd - a pure Java Zstandard (zstd) decoder for Android and the JVM.
What looked like a simple dependency turned into a surprisingly difficult problem.
I needed to decompress zstd-compressed datasets in an Android app. Existing options all had major trade-offs:
- aircompressor 2.x depends on "sun.misc.Unsafe", which crashes on Android ART.
- aircompressor 3.x moved to "java.lang.foreign", which Android doesn't support.
- zstd-jni works well, but requires native ".so" files, ABI-specific packaging, and brings additional complexity with newer Android memory page requirements.
I had to build a pure Java alternative so I ported aircompressor's decoder
The result:
✅ No native code
✅ No "Unsafe"
✅ No "java.lang.foreign"
✅ Android API 26+
✅ JVM 9+
✅ Zero "Unsafe" references in the compiled bytecode (verified)
To make sure it was actually correct, I differentially tested it against libzstd across compression levels 1-22, covering one-shot decompression, streaming, fuzzing, and corruption-boundary tests.
It's decode-only, Apache 2.0 licensed, and completely open source.
If you're building Android or Java applications that consume zstd-compressed data, I hope this saves you a few days of debugging.
implementation("com.qyntrax:unzstd:0.1.0")
GitHub: https://github.com/mbobiosio/unzstd
Feedback, bug reports, and contributions are always welcome.
Top comments (0)