[java] Support JDK 17 (LTS)#3375
Conversation
"JEP 409: Sealed Classes" is now a permanent language feature with Java 17.
JEP 406: Pattern Matching for switch (Preview) Guarded and parenthesized patterns are not implemented yet. More grammar changes to come.
Generated by 🚫 Danger |
Now we can parse guarded patterns in switch labels.
Co-authored-by: Clément Fournier <clement.fournier76@gmail.com>
|
I think we should eventually test rules on some source code written with those new constructs... Otherwise we'll have down the line some bugs in rules that make too many assumptions... Maybe each time we add a new language version we should also publish a small repo with sources and add that to the regression tester project list? We don't have to do this for pmd 6.37.0 though as there's not too much time left |
|
We have some source code that we use for parsing tests under |
This fixes some parsing errors in java files under src/test/resources
|
I've added a test case, which analyzes |
This is apparently not valid.
Both are e.g. I'll fix that. --> 3012462 |
Describe the PR
We probably need to think a bit more about how we model the new case labels "null" and "default" and "guard patterns":
The parenthesis around a pattern are not represented in the AST anymore - which means we can't detect useless parens like in✔️ that's solvedcase ((o instanceof String)) -> ...The "null" switch case label is just a NullLiteral now. The default case label will set the default flag on the switch label.✔️ that's solvedReady?
./mvnw clean verifypasses (checked automatically by github actions)