r/java • u/joemwangi • Mar 17 '26
Updates to Derived Record Creation - amber-spec-experts
https://mail.openjdk.org/archives/list/amber-spec-experts@openjdk.org/thread/QVALXGP2BRN27ISPNJTA3HEKEIMKLWLG/Interesting discussion on the evolution of derived record creation (“withers”). The proposal seems to be shifting from mutation like blocks to a more explicit reconstruction model using obj.new(...), aligning more closely with constructor semantics and pattern matching.
45
Upvotes
View all comments
Show parent comment
9
u/pron98 Mar 17 '26
It was never an attempt to encourage that, nor are we interested in actively encouraging scoping declarations to scopes smaller than a method. If you like doing things this way, fine, but that's not necessarily a better practice.
For somewhat similar reasons, we're not actively encouraging making local variables final. The point is that methods are small enough that you can tell at a glance (and the compiler can infer that, too) how declarations are used. Of course, you're welcome to introduce blocks or break up methods, but we're not interested in necessarily encouraging people to always put declarations in the tiniest sub-method scope; that's mostly a matter of personal taste.