-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Currently for exhaustive switch-expression (JEP 361)
public class SwitchExpressionTarget {
private enum E {
TRUE, FALSE,
}
private static int target(E e) {
return switch (e) {
case TRUE -> 1;
case FALSE -> 0;
};
}
public static void main(String[] args) {
target(E.TRUE);
target(E.FALSE);
}
}with JDK 14 EA b29
$ java --version
openjdk version "14-ea" 2020-03-17
OpenJDK Runtime Environment (build 14-ea+29-1384)
OpenJDK 64-Bit Server VM (build 14-ea+29-1384, mixed mode, sharing)
$ javac --release 14 SwitchExpressionTarget.java
$ java -javaagent:jacoco-0.8.5/lib/jacocoagent.jar SwitchExpressionTarget
$ java -jar jacoco-0.8.5/lib/jacococli.jar \
report jacoco.exec \
--classfiles SwitchExpressionTarget.class \
--sourcefiles . \
--html report
we produce
branch that throws IncompatibleClassChangeError should be filtered out
private static int target(SwitchExpressionTarget$E);
descriptor: (LSwitchExpressionTarget$E;)I
flags: (0x000a) ACC_PRIVATE, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: getstatic #2 // Field SwitchExpressionTarget$1.$SwitchMap$SwitchExpressionTarget$E:[I
3: aload_0
4: invokevirtual #3 // Method SwitchExpressionTarget$E.ordinal:()I
7: iaload
8: lookupswitch { // 2
1: 36
2: 41
default: 46
}
36: iconst_1
37: istore_1
38: goto 54
41: iconst_0
42: istore_1
43: goto 54
46: new #4 // class java/lang/IncompatibleClassChangeError
49: dup
50: invokespecial #5 // Method java/lang/IncompatibleClassChangeError."<init>":()V
53: athrow
54: iload_1
55: ireturn
LineNumberTable:
line 8: 0
line 9: 36
line 10: 41
line 8: 55
fbastien, narner90, ebousse, sll552, Thunderforge and 11 moreexabrialexabrialsvbrunov and exabrial
Metadata
Metadata
Assignees
Type
Projects
Status
Done
