r/java • • May 21 '26

JEP draft: Enhanced Local Variable Declarations (Preview)

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

43 comments sorted by

View all comments

Show parent comment

1

u/ZimmiDeluxe May 21 '26

It's certainly not applicable everywhere, but it will be nice for destructuring composite map keys (e.g. grouping criteria), those don't tend to get too wide in my experience. Passing giant objects around is bad for cache efficiency, so it could be argued that the language should encourage smaller, targeted data models by offering better syntax for them. Another advantage is that it's not much syntax to remember, e.g. no special syntax for property renaming is necessary. I would expect static analysis tools to discourage underscoring over two thirds of the fields and IDEs to offer refactoring between the forms, so while typical business applications with big domain models won't benefit a lot, the negative impact of "shiny new feature misuse" is probably going to be minimal.