Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: support Java 22 language features #16023

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Mar 22, 2024

New language features supported (all described by https://openjdk.org/jeps/456):

  • Anonymous variables (e.g. TypeName _), which can occur in declarations and binding patterns.
  • Anonymous lambda parameters
  • Anonymous patterns (spelled simply _), which can occur in record-pattern context (e.g. MyRecord(int x, _))
  • Multiple patterns in one switch case statement, so long as no pattern declares any binding variables (case A _, B _ when sharedGuard)
  • Fall-through to and from pattern-case statements that don't declare any binding variables (case A _: case "Constant": case MyRecord(_):)

Anonymous variables, lambda parameters and patterns only require pretty-printing and some formatting; they can naturally never take part in dataflow and their names are irrelevant in QL.

Most of the work goes into pattern cases gaining multiple possible patterns (which means the pattern will be entered if one or other pattern matches), and into implementing fall-through. This in particular has consequences for control flow, where pattern-case statements (which normally represent carrying out the type test(s)) need to be circumvented by fall-through flow (e.g. in the context case A _: f(); case B _: g(); break;, the successor of f() is g(), not a type test for B).

@smowton smowton requested a review from a team as a code owner March 22, 2024 14:49
@github-actions github-actions bot added the Java label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant