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
+21
View File
@@ -0,0 +1,21 @@
$ java -jar target/jcstress.jar -t VolatilePublicationTest -jvmArgs "-Xmx256m" -f 2 -iters 15 -time 1000
RUN RESULTS:
Interesting tests: No matches.
Failed tests: No matches.
Error tests: No matches.
All remaining tests: 1 matching test results.
.......... [OK] com.ankurm.jmm.VolatilePublicationTest
Results across all configurations:
RESULT SAMPLES FREQ EXPECT DESCRIPTION
0, 0 4,290,607,784 80.26% Acceptable Reader ran before the write was published at all.
0, 1 0 0.00% Forbidden Would mean the volatile happens-before edge failed to hold.
1, 0 0 0.00% Forbidden Would mean the volatile happens-before edge failed to hold.
1, 1 1,055,076,014 19.74% Acceptable Reader saw the fully-constructed Payload.