jmm: Java Memory Model companion code (volatile, happens-before, DCL)

Runnable jcstress + JUnit companion for the ankurm.com post on the
Java Memory Model, double-checked locking, and the volatile fix.
This commit is contained in:
2026-09-30 05:31:29 +00:00
commit f548d9eeb5
22 changed files with 721 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Quick ad hoc jcstress run against one test class, printed to the terminal instead of
# a captured output/ file. Example:
# ./scripts/run.sh PlainPublicationTest
# ./scripts/run.sh PlainPublicationTest -m tough # extra args pass straight through
set -euo pipefail
cd "$(dirname "$0")/.."
TEST="${1:?Usage: run.sh <TestClassName> [extra jcstress args]}"
shift || true
JAR=target/jcstress.jar
[ -f "$JAR" ] || { echo "Run 'mvn package' first."; exit 1; }
java -jar "$JAR" -t "$TEST" -jvmArgs "-Xmx256m" -f 2 -iters 15 -time 1000 -v "$@"