Accepted
clj-ebpf needs to make Linux syscalls to interact with the BPF subsystem. Traditional approaches include:
- JNI (Java Native Interface) - Requires compiling C code, platform-specific binaries
- JNA (Java Native Access) - Runtime library, slower than JNI
- Panama FFI (Foreign Function & Memory API) - Java 21+ standard API
We needed a solution that:
- Works across architectures (x86_64, aarch64, riscv64)
- Doesn't require external C compilation
- Has good performance for syscall-heavy operations
- Is a stable, supported API
We chose to use Java Panama FFI (Project Panama's Foreign Function & Memory API) for all native interactions.
- No external dependencies: No native libraries to compile or distribute
- Pure Java/Clojure: The entire library is JVM-only code
- Multi-architecture support: Panama works on any platform Java supports
- Performance: Panama's direct memory access is efficient for BPF operations
- Safety: Panama provides memory safety checks
- Java 21+ required: Users must use Java 21 or later (now Java 25+ for full support)
- API changes: Panama was in preview before Java 21; we track stable APIs
- Learning curve: Panama has its own idioms for memory management
- Clear documentation of Java version requirements
- Use of
Arena for automatic memory management - Wrapper functions to hide Panama complexity from library users