Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2021-09-21 12:37:31 +0000
committerJay Arthanareeswaran2021-09-22 07:56:25 +0000
commit72c206c046e77c4139d6101eee427aa67cf19ddd (patch)
tree0b7704d0f26bd219628cb4b19a085e902d930721
parent94dc2600b6cd4a62fd816ab738efb30dee02ea07 (diff)
downloadeclipse.jdt.core-72c206c046e77c4139d6101eee427aa67cf19ddd.tar.gz
eclipse.jdt.core-72c206c046e77c4139d6101eee427aa67cf19ddd.tar.xz
eclipse.jdt.core-72c206c046e77c4139d6101eee427aa67cf19ddd.zip
Bug 576093 - Switch on enum causes VerifyError: Bad type on operand
stack - added test cases (fails on master) Change-Id: Idda71dbff934b1e302a266f02210127deae3311a Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/185652 Tested-by: Jay Arthanareeswaran <jarthana@in.ibm.com> Reviewed-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
index a740b6bd5e..c90cfeacd8 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
@@ -3130,6 +3130,62 @@ public void testBug545518() {
},
message);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=576093
+public void testBug576093a() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) {
+ return;
+ }
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.HashMap;\n"
+ + "import java.util.Map;\n"
+ + "import java.util.Map.Entry;\n"
+ + "\n"
+ + "public class X {\n"
+ + " public static void main(String[] args) {\n"
+ + " Map<Z, Object> map = new HashMap<>();\n"
+ + " for (Entry<Z, Object> entry : map.entrySet()) {\n"
+ + " switch (entry.getKey()) {\n"
+ + " default:\n"
+ + " break;\n"
+ + " }\n"
+ + " }\n"
+ + " System.out.println(\"Success\");\n"
+ + " }\n"
+ + " enum Z {\n"
+ + " A\n"
+ + " }\n"
+ + "}",
+ },
+ "Success");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=576093
+public void testBug576093b() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) {
+ return;
+ }
+ this.runConformTest(
+ new String[] {
+ "X2.java",
+ "import java.util.Optional;\n"
+ + "\n"
+ + "public class X2 {\n"
+ + " public static void main(String[] args) {\n"
+ + " Optional<Z> o = Optional.of(Z.A);\n"
+ + " switch (o.get()) {\n"
+ + " default:\n"
+ + " break;\n"
+ + " }\n"
+ + " System.out.println(\"Success\");\n"
+ + " }\n"
+ + " enum Z {\n"
+ + " A\n"
+ + " }\n"
+ + "}",
+ },
+ "Success");
+}
public static Class testClass() {
return SwitchTest.class;
}

Back to the top