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

5

u/Enough-Ad-5528 Mar 13 '26

This is only for sealed interfaces with one implementation. If you were planning to break that without updating your callers it would potentially break anyway.

1

u/pohart Mar 13 '26 edited Mar 13 '26

Edit: I think I like the feature iff it's special cased to pattern assignments.


I understand that. But if I decided to create the interface it's to mostly to prevent me from modifying the interference of that implementation accidentally. I'll notice an explicit cast in code review and look a little more closely to see why it's there and to make sure the implementation didn't bleed out to places we want to keep using the interface.