Reproduces the pinning JEP 491 did not fix (native JNI frames) with a real native library, alongside the monitor case it did fix. Covers the jdk.VirtualThreadPinned JFR event, reading pinned vs unmounted virtual threads from a jcmd Thread.dump_to_file, the measured throughput cost on a capped carrier pool, and a bounded-executor pattern to contain the blast radius. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FhzLY5p6okFva3qsnsRyvM
19 lines
721 B
Bash
Executable File
19 lines
721 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compiles src/main/c/vtpinning.c into libvtpinning.so, linked against the JNI headers of
|
|
# whichever JDK is on JAVA_HOME (any JDK's jni.h works - the JNI ABI is stable across versions;
|
|
# this repo built it once against JDK 21's headers and loads it fine under JDK 21 and JDK 25).
|
|
# The .so is NOT committed to the repo; run this before the other scripts.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
: "${JAVA_HOME:?Set JAVA_HOME to a JDK install (its include/ dir must have jni.h)}"
|
|
|
|
mkdir -p target/native
|
|
gcc -shared -fPIC \
|
|
-I"$JAVA_HOME/include" \
|
|
-I"$JAVA_HOME/include/linux" \
|
|
-o target/native/libvtpinning.so \
|
|
src/main/c/vtpinning.c
|
|
|
|
echo "Built target/native/libvtpinning.so"
|