Community
Participate
Working Groups
Created the test case on the basis of a note from Remi (Thanks)! Given: public class X { private int foo(Integer o) { switch(o) { case null, Integer i -> System.out.println("hh"); } return 0; } } This gives an "Illegal fall-through error". As per the JEP. 406 Section 14.11.1, this is allowed: "If a switch label has a null case label element then if the switch label also has any pattern case element labels, they must be type patterns (14.30.1)." On a side-note, "case Integer i, null -> " works. This fell through the cracks although we had a test case (testBug574563_002) covering this scenario but had additional errors which did not cause this error.
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/185138
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/185850
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/185850 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=4a3c14689ab8397c779ed5b4a8e037a76e73d74d
This change makes NullAnnotationTests17.test_switchNullInSameCase() fail. While it's easy to adjust the test expectation I wonder if gerrit jobs actually test against JRE 17 / with -Dcompliance=17?
(In reply to Stephan Herrmann from comment #4) > This change makes NullAnnotationTests17.test_switchNullInSameCase() fail. > > While it's easy to adjust the test expectation I wonder if gerrit jobs > actually test against JRE 17 / with -Dcompliance=17? After updating the gerrit jenkins job to JRE 17 & compliance 17, those builds consistently fail for this bug and bug 576026. To unblock that deadlock, I'm fixing both issues in one gerrit: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/186875
I should add, that adjusting the expectation wasn't exactly a good idea: previously, null analysis didn't have to care about "case null, Integer i -> " because originally that was illegal to begin with. The gerrit enhances analysis to detect that 'i' is potentially null in this situation.
(In reply to Stephan Herrmann from comment #5) > (In reply to Stephan Herrmann from comment #4) > > This change makes NullAnnotationTests17.test_switchNullInSameCase() fail. > > > > While it's easy to adjust the test expectation I wonder if gerrit jobs > > actually test against JRE 17 / with -Dcompliance=17? > > After updating the gerrit jenkins job to JRE 17 & compliance 17, those > builds consistently fail for this bug and bug 576026. To unblock that > deadlock, I'm fixing both issues in one gerrit: > https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/186875 This regression fix has been released to master.
(In reply to Stephan Herrmann from comment #7) > > This regression fix has been released to master. @Stephan: Thanks a lot for taking care of the regression - got busy with the sessions in EclipseCon in the last two days - catching up on the bugs now. Since JEP 420 draft is out for second preview, I have added Bug 576910 as a separate bug for null analysis there to check for any changes due to the delta in the new jep.
Verified for 4.22 M3 using build I20211110-1800