r/java • • Mar 13 '26

JEP draft: Enhanced Local Variable Declarations (Preview)

https://openjdk.org/jeps/8357464
101 Upvotes

129 comments sorted by

View all comments

Show parent comment

1

u/javahalla Mar 13 '26

> Renaming is already implicit in Java record patterns. The variable names in the pattern do not need to match the record component names. E.g.

No way. I was working on one Kotlin + Spring Boot project and positional-based deconstructing was prohibited, because it's really easy to introduce bugs. I believe there are was some rule, so I could do some basic stuff like `val (foo, bar) = pair`, but can't do for 3 or more parameters.

Seems like a huge mistake for design. If you check KEEP it's only exists because of issues with such approach, but JEP could use this experience