-
Notifications
You must be signed in to change notification settings - Fork 340
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
Support JEP-440 and 441 #4661
base: main
Are you sure you want to change the base?
Support JEP-440 and 441 #4661
Conversation
Aren't some of the tests (like record pattern matching) for preview only features? So far we haven't supported any preview features and people haven't really asked for it either. |
Small bug fix
As far as I understand it, both 440/441 have been delivered/closed (see status in 440 and 441) and have been included in the release of Java 21 as permanent JEPs (source: https://www.jrebel.com/blog/java-21). I double-checked by running some of the code snippets in these using Java |
I think you are right. I missed that! |
What's changed?
Initial test cases for verifying parser support for JEP 440 and 441. The goal of these tests is to demonstrate that code containing JEP 440/441 structures remains unchanged. The tests very closely resemble the code snippets used in the JEPs themselves to describe their changes. They can be summarized as follows:
Pattern Switch Statement
Verifies that switch expressions using patterns for different object types (e.g., Integer, Long, Double, String) maintain structure after parsing.
Pattern Matching for Records
Tests parsing of instanceof with record deconstruction (e.g., if (obj instanceof Point(int x, int y))), ensuring that records can be deconstructed and match syntax remains unchanged.
Nested Pattern Matching for Records and Enums
Ensures that nested pattern matching with records containing other records and enums (e.g., Rectangle(ColoredPoint(Point p, Color c), ColoredPoint lr)) is correctly handled and maintains structure.
null Case Handling in Switch Statements
Checks that switch cases with null handling (e.g., case null ->)
Improved Enum Support with Sealed Types
Tests switch handling for sealed types and enums (e.g., case Foo.CLUBS, case Bar b) to ensure that sealed interfaces with enums and final classes maintain parsing integrity.
Relaxed Type Restrictions in Switch Statements
Verifies that switch cases with mixed types (e.g., String, Color, Point, int[]) correctly serialize and deserialize while preserving type information.
Special Integer Cases in Switch
Tests specific integer cases and when clauses (e.g., case -1, 1, case Integer j when (j - 1) > -1) in switch statements, ensuring all conditional logic remains intact after parsing.
What's your motivation?
Provide support for JEP 440/441
Checklist