Pak
is a Kotlin Multiplatform library that wraps zlib
in a safe and well-structured API.
With the introduction of Java 22, the Foreign Function and Memory interface
can be leveraged to utilize native zlib
over the less flexible java.util.zip
package.
Pak/JVM embeds a Rust library located in the pak-rs
subproject. This library loads zlib and wraps it with
an interface designed for the Java world. Therefore, zlib
must be installed on the host machine. A user may select a
specific implementation with the ZLIB_LIBRARY
environment variable, otherwise a selection is made between libz.so
,
libz.dylib
, or zlib1.dll
.
Kotlin/Native comes pre-configured with bindings to zlib
, which Pak
employs internally. Therefore, Pak/Native
hosts require their native zlib
only. Depending on the host platform, a specific zlib
implementation may be usable
over the default implementation.
Kotlin/JS is supported with the excellent pako
zlib implementation. This allows Pak
to work in any JavaScript environment, with minimal overhead.