https://github.com/dfa1/zstd-java
Java FFM (Foreign Function & Memory) bindings for zstd — hermetic zig build, dictionary support, zero-copy MemorySegment API
https://github.com/dfa1/zstd-java
Last synced: 10 days ago
JSON representation
Java FFM (Foreign Function & Memory) bindings for zstd — hermetic zig build, dictionary support, zero-copy MemorySegment API
- Host: GitHub
- URL: https://github.com/dfa1/zstd-java
- Owner: dfa1
- License: other
- Created: 2026-06-25T19:58:12.000Z (12 days ago)
- Default Branch: main
- Last Pushed: 2026-06-26T07:05:11.000Z (11 days ago)
- Last Synced: 2026-06-26T07:20:08.220Z (11 days ago)
- Language: Java
- Size: 191 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Support: docs/supported.md
Awesome Lists containing this project
README
# zstd-java
[](https://github.com/dfa1/zstd-java/actions/workflows/ci.yml)
[](https://sonarcloud.io/summary/new_code?id=dfa1_zstd-java)
[](https://sonarcloud.io/summary/new_code?id=dfa1_zstd-java)
[](https://central.sonatype.com/artifact/io.github.dfa1.zstd/zstd)


[](LICENSE)
**zstd-java** is a Java wrapper for [Zstandard](https://github.com/facebook/zstd)
built on the **Foreign Function & Memory (FFM) API** — no JNI, no `sun.misc.Unsafe`.
It targets **JDK 25+** (for stable `java.lang.foreign`) and leads with the
feature missing from most JVM zstd bindings: **dictionary compression**, trained
straight from your own data.
> **AI-assisted development:** This project uses Claude Code for implementation —
> C header mapping, test generation, docs. Architecture, API design, and all
> decisions are human-driven.
## Documentation
The docs follow the [Diátaxis](https://diataxis.fr) framework:
| | Purpose | Start here |
|---|---|---|
| **[Tutorial](docs/tutorial.md)** | Learning by doing | Clean checkout → first round-trip |
| **[How-to guides](docs/how-to.md)** | Solving a specific task | Hot paths, dictionaries, zero-copy, self-built lib |
| **[Reference](docs/reference.md)** | Looking up facts | Platforms, API surface, symbol coverage, build |
| **[Explanation](docs/explanation.md)** | Understanding the why | Why FFM + Zig, when zero-copy pays, benchmarks |
Architecture decisions are recorded as [ADRs](adr/ADR.md) (MADR 3.0) — the
foundational choices and their trade-offs, one file per decision.
## Install
The `zstd` jar is pure Java and ships no `libzstd` — you always pair it with a
native artifact. Two ways:
**1. Everything, any platform** — one dependency on `zstd-platform`, an empty jar
that transitively pulls the bindings plus all six natives (~3.8 MB). Zero choices;
the build runs on any OS/arch.
```xml
io.github.dfa1.zstd
zstd-platform
0.4
```
**2. Leaner, one platform** — import `zstd-bom` to pin versions, then take `zstd`
plus only the `zstd-native-` you target.
```xml
io.github.dfa1.zstd
zstd-bom
0.4
pom
import
io.github.dfa1.zstd
zstd
io.github.dfa1.zstd
zstd-native-osx-aarch64
runtime
```
Classifiers: `osx-aarch64`, `osx-x86_64`, `linux-x86_64`, `linux-aarch64`,
`windows-x86_64`, `windows-aarch64`. Gradle and more detail in the
[tutorial](docs/tutorial.md). Requires JDK 25+ and
`--enable-native-access=ALL-UNNAMED` at runtime. Building from source is for
contributors — see the [reference](docs/reference.md).
## License
[BSD 3-Clause](LICENSE) — the same primary license as zstd, which is bundled
under its BSD terms (zstd is dual BSD / GPLv2, © Meta Platforms, Inc.).