https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 has finally been fixed. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>tags/V1_9_21_RC1
} | } | ||||
Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { | Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { | ||||
// This used to work in preview 4 (Java 20), but fails during runtime with | |||||
// java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 4 | |||||
// in ECJ 3.36.0-SNAPSHOT with Java 21. | |||||
// See: | |||||
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466. | |||||
// | |||||
// TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. | |||||
/* | |||||
System.out.println( | System.out.println( | ||||
switch (i) { | switch (i) { | ||||
case null -> "value unavailable: " + i; | case null -> "value unavailable: " + i; | ||||
default -> "other integer: " + i; | default -> "other integer: " + i; | ||||
} | } | ||||
); | ); | ||||
*/ | |||||
return proceed(i); | return proceed(i); | ||||
} | } | ||||
} | } |
// constantLabelMustAppearBeforePattern(Integer.valueOf(123)); | // constantLabelMustAppearBeforePattern(Integer.valueOf(123)); | ||||
// constantLabelMustAppearBeforePattern(null); | // constantLabelMustAppearBeforePattern(null); | ||||
// TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. | |||||
/* | |||||
constantLabelMustAppearBeforePatternInteger(-1); | constantLabelMustAppearBeforePatternInteger(-1); | ||||
constantLabelMustAppearBeforePatternInteger(0); | constantLabelMustAppearBeforePatternInteger(0); | ||||
constantLabelMustAppearBeforePatternInteger(42); | constantLabelMustAppearBeforePatternInteger(42); | ||||
constantLabelMustAppearBeforePatternInteger(-99); | constantLabelMustAppearBeforePatternInteger(-99); | ||||
constantLabelMustAppearBeforePatternInteger(Integer.valueOf(123)); | constantLabelMustAppearBeforePatternInteger(Integer.valueOf(123)); | ||||
constantLabelMustAppearBeforePatternInteger(null); | constantLabelMustAppearBeforePatternInteger(null); | ||||
*/ | |||||
System.out.println(testGenericSealedExhaustive(new E<Integer>())); | System.out.println(testGenericSealedExhaustive(new E<Integer>())); | ||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
/** | |||||
* This used to work in preview 4 (Java 20), but fails during runtime with | |||||
* java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 4 | |||||
* in ECJ 3.36.0-SNAPSHOT with Java 21. | |||||
* See: | |||||
* https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466. | |||||
* | |||||
* TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. | |||||
*/ | |||||
static String constantLabelMustAppearBeforePatternInteger(Integer i) { | static String constantLabelMustAppearBeforePatternInteger(Integer i) { | ||||
switch (i) { | switch (i) { | ||||
case null -> System.out.println("value unavailable: " + i); | case null -> System.out.println("value unavailable: " + i); |
<ajc-test dir="features1921/java21" vm="21" title="switch pattern matching preview 4 java"> | <ajc-test dir="features1921/java21" vm="21" title="switch pattern matching preview 4 java"> | ||||
<compile files="SwitchPatternPreview4OK.java" options="-21" /> | <compile files="SwitchPatternPreview4OK.java" options="-21" /> | ||||
<run class="SwitchPatternPreview4OK" vmargs=""> | <run class="SwitchPatternPreview4OK" vmargs=""> | ||||
<message></message> | |||||
<message/> | |||||
<stdout> | <stdout> | ||||
<line text="null" /> | <line text="null" /> | ||||
<line text="int 123" /> | <line text="int 123" /> | ||||
<line text="Sealed sub-class A" /> | <line text="Sealed sub-class A" /> | ||||
<line text="Sealed sub-class B" /> | <line text="Sealed sub-class B" /> | ||||
<line text="Sealed sub-record C" /> | <line text="Sealed sub-record C" /> | ||||
<!-- TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. --> | |||||
<!-- | |||||
<line text="absolute value 1: -1" /> | <line text="absolute value 1: -1" /> | ||||
<line text="other integer: 0" /> | <line text="other integer: 0" /> | ||||
<line text="positive integer: 42" /> | <line text="positive integer: 42" /> | ||||
<line text="other integer: -99" /> | <line text="other integer: -99" /> | ||||
<line text="positive integer: 123" /> | <line text="positive integer: 123" /> | ||||
<line text="value unavailable: null" /> | <line text="value unavailable: null" /> | ||||
--> | |||||
<line text="42" /> | <line text="42" /> | ||||
</stdout> | </stdout> | ||||
</run> | </run> | ||||
<line text="Sealed sub-class A" /> | <line text="Sealed sub-class A" /> | ||||
<line text="Sealed sub-class B" /> | <line text="Sealed sub-class B" /> | ||||
<line text="Sealed sub-record C" /> | <line text="Sealed sub-record C" /> | ||||
<!-- TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. --> | |||||
<!-- | |||||
<line text="absolute value 1: -1" /> | <line text="absolute value 1: -1" /> | ||||
<line text="other integer: 0" /> | <line text="other integer: 0" /> | ||||
<line text="positive integer: 42" /> | <line text="positive integer: 42" /> | ||||
<line text="other integer: -99" /> | <line text="other integer: -99" /> | ||||
<line text="positive integer: 123" /> | <line text="positive integer: 123" /> | ||||
<line text="value unavailable: null" /> | <line text="value unavailable: null" /> | ||||
--> | |||||
</stdout> | </stdout> | ||||
</run> | </run> | ||||
</ajc-test> | </ajc-test> |