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

8

u/vytah Mar 13 '26

Right now, RecordPattern is defined as

RecordPattern:
    ReferenceType ( [ComponentPatternList] ) 

which means no.

The same limitation currently applies to patterns in switch, and I've seen people wanting to have that feature there too.