Add lazy-constants module: LazyConstant (JEP 531) against the holder idiom and double-checked locking
Basics, failure semantics on 26 vs 27, lazy collections, API across 25/26/27, preview-flag traps and a JMH read-path benchmark (jars fetched and sha1-checked, not committed). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
$ javac broken/NoPreviewFlag.java (27+35)
|
||||
broken/NoPreviewFlag.java:3: error: LazyConstant is a preview API and is disabled by default.
|
||||
static final LazyConstant<String> CONFIG = LazyConstant.of(() -> "x");
|
||||
^
|
||||
(use --enable-preview to enable preview APIs)
|
||||
broken/NoPreviewFlag.java:3: error: LazyConstant is a preview API and is disabled by default.
|
||||
static final LazyConstant<String> CONFIG = LazyConstant.of(() -> "x");
|
||||
^
|
||||
(use --enable-preview to enable preview APIs)
|
||||
2 errors
|
||||
exit=1
|
||||
|
||||
$ javap -v Basics | grep 'major\|minor' (27+35, compiled with --enable-preview --release 27)
|
||||
minor version: 65535
|
||||
major version: 71
|
||||
|
||||
$ java Basics (27+35, without --enable-preview)
|
||||
Error: LinkageError occurred while loading main class Basics
|
||||
java.lang.UnsupportedClassVersionError: Preview features are not enabled for Basics (class file version 71.65535). Try running with '--enable-preview'
|
||||
|
||||
$ java --enable-preview Basics (26.0.2.1+1, class file built by 27)
|
||||
Error: LinkageError occurred while loading main class Basics
|
||||
java.lang.UnsupportedClassVersionError: Basics has been compiled by a more recent version of the Java Runtime (class file version 71.65535), this version of the Java Runtime only recognizes class file versions up to 70.0
|
||||
Reference in New Issue
Block a user