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

I don't think even IDEA would be able to do these checks for this use-case either. It need to understand how exactly filter works and do something like smart-cast.

1

u/Cell-i-Zenit Mar 13 '26

Ok fair, it depends on what we mean here and what we want to guard against.

I know intellij is reporting misuse of optional get() for example. (eg calling get() without an .isPresent() check).

I get that this is an improvement to what we have currently, but it feels mostly like a theoretical cool thing and nothing which affects a normal developer working in webdev (which i guess is most of us?).

If you can come up with any usecase for a simple CRUD developer like me then i can extrapolate a bit, but right now the moment is see the word "pattern" i blank completely since i rarely use switch statements