#!/usr/bin/env bash # Regenerates every file in ../output/. Requires JDK25_HOME. Every demo in this module needs # --enable-preview to run (ScopedValueDemo uses StructuredTaskScope, still preview in JDK 25/26), # even though ScopedValue itself is finalized (JEP 506). set -euo pipefail if [[ -z "${JDK25_HOME:-}" ]]; then echo "JDK25_HOME must be set (e.g. /path/to/jdk-25)" >&2 exit 1 fi cd "$(dirname "$0")/.." OUT=output mkdir -p "$OUT" JAVA_HOME="$JDK25_HOME" mvn -q -f ../pom.xml -pl concurrency-interview package run() { local class=$1 local outfile=$2 echo "==> $class" "$JDK25_HOME/bin/java" --enable-preview -cp target/classes "com.ankurm.concurrencyinterview.$class" 2>&1 | grep -v "Picked up" > "$OUT/$outfile" } run RaceConditionDemo 01-race-condition.txt run VolatileNotEnoughDemo 02-volatile-not-enough.txt run DeadlockDemo 03-deadlock-detection.txt run ScopedValueDemo 04-scoped-value-inheritance.txt cp target/surefire-reports/com.ankurm.concurrencyinterview.InterviewClaimsTest.txt "$OUT/05-correctness-tests.txt" echo "Done. See $OUT/"