Runtime extraction of bundled native agent binaries.
Extracts platform-specific agent binaries from JAR resources to temporary directory for loading. Handles concurrent extraction safely using file locking and registers shutdown hooks for cleanup.
The extraction process:
Extraction is persistent by default: the extracted binary is NOT deleted
when the JVM exits. The temp filename is content-addressed (includes the
SHA256 hash), so the file is reused across runs and JAR versions, and a path
produced in one JVM remains valid for a separately-launched JVM (for example
the -agentpath returned by criterium.agent/jvm-opts). Deletion on JVM exit
is available as an explicit opt-in for ephemeral in-process use.
Thread-safe and safe for concurrent JVM processes.
Runtime extraction of bundled native agent binaries. Extracts platform-specific agent binaries from JAR resources to temporary directory for loading. Handles concurrent extraction safely using file locking and registers shutdown hooks for cleanup. The extraction process: 1. Detects current platform 2. Reads SHA256 hash from bundled .sha256 file 3. Checks if agent already extracted to temp directory 4. If not, locks and extracts atomically 5. Sets appropriate file permissions (executable on Unix) 6. Verifies file permissions 7. Returns absolute path to extracted agent Extraction is persistent by default: the extracted binary is NOT deleted when the JVM exits. The temp filename is content-addressed (includes the SHA256 hash), so the file is reused across runs and JAR versions, and a path produced in one JVM remains valid for a separately-launched JVM (for example the `-agentpath` returned by `criterium.agent/jvm-opts`). Deletion on JVM exit is available as an explicit opt-in for ephemeral in-process use. Thread-safe and safe for concurrent JVM processes.
(extract-agent)(extract-agent {:keys [cleanup-on-exit?] :or {cleanup-on-exit? false}})Extract bundled agent binary to temp directory.
Returns the absolute path to the extracted agent, or nil only when the platform is unsupported (a legitimate, non-error outcome).
Throws a structured extraction error (carrying :stage and context) for any genuine failure - missing hash file, missing binary resource, copy/lock/move failures, hash mismatch, or permission problems. Failures are never silently swallowed.
By default the extracted file is persistent: it is NOT deleted on JVM
shutdown, so the returned path remains valid for a separately-launched JVM
(such as one started with the -agentpath produced by
criterium.agent/jvm-opts). The temp filename is content-addressed, so the
file is safely reused across runs.
Options:
Safe to call concurrently from multiple threads or processes.
Extract bundled agent binary to temp directory. Returns the absolute path to the extracted agent, or nil only when the platform is unsupported (a legitimate, non-error outcome). Throws a structured extraction error (carrying :stage and context) for any genuine failure - missing hash file, missing binary resource, copy/lock/move failures, hash mismatch, or permission problems. Failures are never silently swallowed. By default the extracted file is persistent: it is NOT deleted on JVM shutdown, so the returned path remains valid for a separately-launched JVM (such as one started with the `-agentpath` produced by `criterium.agent/jvm-opts`). The temp filename is content-addressed, so the file is safely reused across runs. Options: - :cleanup-on-exit? (default false) - when true, registers a JVM shutdown hook to delete the extracted file on exit. Only appropriate for ephemeral, in-process use where no other JVM will load the path. Safe to call concurrently from multiple threads or processes.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |