r/java • u/bobbie434343 • Aug 25 '26
Value Classes Still Need Compiler Sympathy
https://johan-sjolen.github.io/post/compiler-sympathy/compiler-sympathy/
88
Upvotes
r/java • u/bobbie434343 • Aug 25 '26
View all comments
Show parent comment
13
u/brian_goetz Aug 25 '26 edited Aug 26 '26
No, developers don't need to learn to read C2 code. They need to learn to use value classes when it makes sense semantically and stop trying to second-guess the runtime. "Will it flatten" is the new "will it inline"; 99.99% of developers should not even ask.
You also seem to have a misunderstanding of the approach to non-atomicity (the possibility of tearing). These internal annotations are just that -- internal. They are for the use of the JDK (written by experts with an understanding of the tradeoffs.) These will never be opened up for general use; the concepts will first need to be integrated into the language model, and they will surely then take a different form. This isn't done yet, so any statements about "what they are going to do" will surely be wrong.
What you're seeing is what the early adopters are doing, because those are the folks who can't resist taking apart the radio to see how it works. Which is fine -- but not what we are optimizing for.