#!/usr/bin/env bash # Confirms -Djdk.tracePinnedThreads=full is inert on this JDK (JEP 491, GA in JDK 24). # Pre-JDK-24, this flag made a pinned virtual thread print a stack trace to stdout while # pinned. Runs PinningTraceCheckMain (which holds a monitor across Thread.sleep(200) on a # virtual thread) once without the flag and once with it, and diffs stdout. Output: # docs/output/03b-trace-pinned-threads-removed.txt. See docs/03-pinning-diagnosis.md. set -euo pipefail cd "$(dirname "$0")/.." mkdir -p docs/output OUT=docs/output/03b-trace-pinned-threads-removed.txt echo "java -version:" > "$OUT" java -version 2>&1 | grep -v "^Picked up JAVA_TOOL_OPTIONS" >> "$OUT" echo "" >> "$OUT" echo "-- without -Djdk.tracePinnedThreads=full --" >> "$OUT" java -cp target/classes com.ankurm.vthreads.PinningTraceCheckMain 2>&1 | grep -v "^Picked up JAVA_TOOL_OPTIONS" >> "$OUT" echo "" >> "$OUT" echo "-- with -Djdk.tracePinnedThreads=full --" >> "$OUT" java -Djdk.tracePinnedThreads=full -cp target/classes com.ankurm.vthreads.PinningTraceCheckMain 2>&1 | grep -v "^Picked up JAVA_TOOL_OPTIONS" >> "$OUT" echo "" >> "$OUT" if grep -q "Thread\[#" "$OUT" && grep -qi "monitors:" "$OUT"; then echo "RESULT: a pinned-thread stack trace WAS printed -- flag still functional on this JDK" >> "$OUT" else echo "RESULT: no pinned-thread stack trace was printed by either run -- the flag is inert on this JDK, consistent with JEP 491" >> "$OUT" fi cat "$OUT"