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,13 @@
|
||||
$ javac --enable-preview --release 26 src/Failures.java && java --enable-preview Failures (26.0.2.1+1)
|
||||
get #1: java.lang.IllegalStateException: boom | cause=null | supplier calls=1
|
||||
get #2: java.lang.IllegalStateException: boom | cause=null | supplier calls=2
|
||||
get #3: java.lang.IllegalStateException: boom | cause=null | supplier calls=3
|
||||
null result: java.lang.NullPointerException | cause=null
|
||||
recursion: java.lang.IllegalStateException: Recursive invocation of a LazyConstant's computing function: Failures$$Lambda | cause=null
|
||||
|
||||
$ javac --enable-preview --release 27 src/Failures.java && java --enable-preview Failures (27+35)
|
||||
get #1: java.util.NoSuchElementException: Unable to access the constant because java.lang.IllegalStateException was thrown at initial computation | cause=java.lang.IllegalStateException: boom | supplier calls=1
|
||||
get #2: java.util.NoSuchElementException: Unable to access the constant because java.lang.IllegalStateException was thrown at initial computation | cause=null | supplier calls=1
|
||||
get #3: java.util.NoSuchElementException: Unable to access the constant because java.lang.IllegalStateException was thrown at initial computation | cause=null | supplier calls=1
|
||||
null result: java.util.NoSuchElementException: Unable to access the constant because java.lang.NullPointerException was thrown at initial computation | cause=java.lang.NullPointerException
|
||||
recursion: java.util.NoSuchElementException: Unable to access the constant because java.lang.IllegalStateException was thrown at initial computation | cause=java.lang.IllegalStateException: Recursive invocation of a LazyConstant's computing function: Failures$$Lambda
|
||||
Reference in New Issue
Block a user