Add java21-to-25 module: compile-once probes on JDK 21 and 25, removed APIs, build matrix, pinning, compact headers and containers

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7N4ZDbUtA3ofqAqRV
This commit is contained in:
Claude
2026-12-03 09:26:21 +05:30
parent d4b8552957
commit 3502fd7804
46 changed files with 1371 additions and 0 deletions
@@ -0,0 +1,49 @@
# 03-source-and-preview: preview code written for 21, and 25 APIs tried on 21
=== StringTemplateDemo: compile on 21 with --enable-preview, run on 21
Hello Ankur
=== StringTemplateDemo: run the same class on 25 (with --enable-preview)
Error: LinkageError occurred while loading main class StringTemplateDemo
java.lang.UnsupportedClassVersionError: StringTemplateDemo (class file version 65.65535) was compiled with preview features that are unsupported. This version of the Java Runtime only recognizes preview features for class file version 69.65535
=== StringTemplateDemo: recompile the source on 25 with --enable-preview
src/preview21/StringTemplateDemo.java:5: error: illegal escape character
System.out.println(STR."Hello \{name}");
^
1 error
=== StructuredTaskDemo: compile on 21 with --enable-preview, run on 21
user-7 order-42
=== StructuredTaskDemo: run the same class on 25 (with --enable-preview)
Error: LinkageError occurred while loading main class StructuredTaskDemo
java.lang.UnsupportedClassVersionError: StructuredTaskDemo (class file version 65.65535) was compiled with preview features that are unsupported. This version of the Java Runtime only recognizes preview features for class file version 69.65535
=== StructuredTaskDemo: recompile the source on 25 with --enable-preview
src/preview21/StructuredTaskDemo.java:6: error: cannot find symbol
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
^
symbol: class ShutdownOnFailure
location: interface StructuredTaskScope
1 error
=== ThreadSuspendCall.java: javac on 21, then 25
21 exit 0
src/broken/ThreadSuspendCall.java:4: error: cannot find symbol
t.suspend();
^
symbol: method suspend()
location: variable t of type Thread
1 error
=== ScopedValueDemo.java: javac on 21
src/new25/ScopedValueDemo.java:3: error: ScopedValue is a preview API and is disabled by default.
private static final ScopedValue<String> REQUEST_ID = ScopedValue.newInstance();
^
(use --enable-preview to enable preview APIs)
=== ScopedValueDemo.java: javac and java on 25, no flags
handling req-17 on main
bound outside the scope: false
=== GathererDemo.java: javac on 21
src/new25/GathererDemo.java:2: error: cannot find symbol
import java.util.stream.Gatherers;
^
symbol: class Gatherers
=== GathererDemo.java: javac and java on 25, no flags
[[1, 2], [3, 4], [5]]
[[1, 2, 3], [2, 3, 4]]
[1, 3, 6, 10]
[A, B, C]