Files
javademos/lazy-constants/output/06-preview-flags.txt
T
Claude 814c32b5ce 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
2026-09-24 12:27:27 +00:00

24 lines
1.3 KiB
Plaintext

$ 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