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,26 @@
|
||||
$ javac --enable-preview --release 27 src/LazyCollections.java && java --enable-preview LazyCollections (27+35)
|
||||
list created, size 3 (nothing computed yet)
|
||||
computing list element 1
|
||||
list.get(1) = v1
|
||||
list.get(1) again = v1
|
||||
map created, size 3 (nothing computed yet)
|
||||
computing map value for bb
|
||||
map.get("bb") = 2
|
||||
map.get("bb") again = 2
|
||||
set created
|
||||
testing 2
|
||||
set.contains(2) = true
|
||||
testing 1
|
||||
set.contains(1) = false
|
||||
set.contains(9) = false
|
||||
testing 3
|
||||
set.size() = 2
|
||||
|
||||
$ javac --enable-preview --release 26 src/LazyCollections.java (26.0.2.1+1)
|
||||
src/LazyCollections.java:18: error: cannot find symbol
|
||||
Set<Integer> set = Set.ofLazy(Set.of(1, 2, 3), n -> { System.out.println(" testing " + n); return n > 1; });
|
||||
^
|
||||
symbol: method ofLazy(Set<Integer>,(n)->{ Sys[...] 1; })
|
||||
location: interface Set
|
||||
1 error
|
||||
exit=1
|
||||
Reference in New Issue
Block a user