completablefuture: CompletableFuture module (thenApply vs thenCompose and the serial trap, which thread runs a stage incl. join() running dependents, CompletionException wrapping, orTimeout/cancel not stopping work, allOf/anyOf with fail-fast and first-success helpers, virtual-thread timings, StructuredTaskScope preview error), 26 contract tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b3dRuKRhrHFPzWSSxr
This commit is contained in:
Ankur Mhatre
2026-11-22 18:56:47 +05:30
co-authored by Claude Sonnet 5.5
parent 59a5435825
commit 9c2ae10d7f
25 changed files with 1335 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Captures the compiler's own message for src/broken/StructuredScopeWithoutPreview.java.
set -uo pipefail
cd "$(dirname "$0")/.."
mkdir -p output target/broken
javac -d target/broken src/broken/StructuredScopeWithoutPreview.java 2>&1 \
| grep -v -e '^Picked up JAVA_TOOL_OPTIONS' -e '^Picked up _JAVA_OPTIONS' > output/08-structured-scope-without-preview.txt
echo "==> 08-structured-scope-without-preview"
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Regenerates every file in output/. Needs a JDK 25 on PATH (or JAVA_HOME set to one).
# 03 (join counts) and 07 (timings) drift between runs and depend on core count: indicative only.
set -euo pipefail
cd "$(dirname "$0")/.."
mvn -q -B compile 2>&1 | grep -v -e '^WARNING' -e '^Picked up' || true
mkdir -p output
run() { java -cp target/classes "com.ankurm.completablefuture.$1" 2>&1 | grep -v -e '^Picked up JAVA_TOOL_OPTIONS' -e '^Picked up _JAVA_OPTIONS' > "output/$2.txt"; echo "==> $2"; }
run ThenApplyVsComposeDemo 01-thenapply-vs-thencompose
run WhichThreadDemo 02-which-thread
run JoinHelpsDemo 03-join-helps
run ExceptionHandlingDemo 04-exception-handling
run TimeoutDemo 05-timeouts-and-cancel
run AllOfAnyOfDemo 06-allof-anyof
run VirtualThreadsBenchmark 07-virtual-threads-timings
./scripts/compile-broken.sh
mvn -B test 2>&1 | grep -E 'Tests run:|BUILD|ERROR|FAIL' | grep -v 'Picked up' > output/09-tests.txt
echo "regenerated:"; ls output