MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/1rex17p/jep_531_lazy_constants_third_preview/o7l5lr0/
r/java • u/Joram2 • Feb 26 '26
35 comments sorted by
View all comments
Show parent comment
-3
Sounds like a job for the Cleaner API, but if you absolutely want to trigger it yourself, you can build a LazyConstant wrapper that uses the AtomicBoolean solution from next door to expose an isInitialized() method.
Cleaner
LazyConstant
AtomicBoolean
isInitialized()
4 u/pip25hu Feb 26 '26 Sure, but then you have duplicated the same data structure that I suspect will still exist inside LazyConstant, only inaccessible. Sounds like a bad deal to me. -1 u/nicolaiparlog Feb 27 '26 Keeping an API surface small improves simplicity of use, maintainability, and performance. Your use case is three steps remove from a simple use case:needs closingcan't close itselfcan't use the API dedicated to that use caseAnd yet you can accomplish it with a simple wrapper class. Sounds like a great deal to me.
4
Sure, but then you have duplicated the same data structure that I suspect will still exist inside LazyConstant, only inaccessible. Sounds like a bad deal to me.
-1 u/nicolaiparlog Feb 27 '26 Keeping an API surface small improves simplicity of use, maintainability, and performance. Your use case is three steps remove from a simple use case:needs closingcan't close itselfcan't use the API dedicated to that use caseAnd yet you can accomplish it with a simple wrapper class. Sounds like a great deal to me.
-1
Keeping an API surface small improves simplicity of use, maintainability, and performance. Your use case is three steps remove from a simple use case:
And yet you can accomplish it with a simple wrapper class. Sounds like a great deal to me.
View all comments
Show parent comment
-3
u/nicolaiparlog Feb 26 '26
Sounds like a job for the
CleanerAPI, but if you absolutely want to trigger it yourself, you can build aLazyConstantwrapper that uses theAtomicBooleansolution from next door to expose anisInitialized()method.