diff options
author | Manoj Palat | 2019-09-19 13:45:39 +0000 |
---|---|---|
committer | Manoj Palat | 2019-09-20 05:36:13 +0000 |
commit | d629b1096b8cb254d581d898bc8e532a43fadd9d (patch) | |
tree | 3e9b4b771a5da351654c2866cb99842d66ad9a03 | |
parent | 9407f9ff6ccc3c7dccbee9bda158370adbe122c7 (diff) | |
download | eclipse.jdt.core-d629b1096b8cb254d581d898bc8e532a43fadd9d.tar.gz eclipse.jdt.core-d629b1096b8cb254d581d898bc8e532a43fadd9d.tar.xz eclipse.jdt.core-d629b1096b8cb254d581d898bc8e532a43fadd9d.zip |
Bug 544943 - [13][codegen] Exception while codegen for multi-nested
switch expression with try
Change-Id: If308f35a7b4db048c3e4c80b234f6aff4198aa9a
2 files changed, 62 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java index 351dc4bf16..32efd3c180 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java @@ -2921,7 +2921,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest { "Duplicate case\n" + "----------\n"); } - public void testBug544943() { + public void _testBug544943() { runConformTest( new String[] { "X.java", @@ -2956,7 +2956,7 @@ public class SwitchExpressionTest extends AbstractRegressionTest { }, "1"); } - public void testBug544943_2() { + public void _testBug544943_2() { runConformTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java index f0dd255882..8c981768d0 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java @@ -3480,4 +3480,64 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest { "String literal is not properly closed by a double-quote\n" + "----------\n"); } + public void testBug544943() { + runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " @SuppressWarnings(\"preview\")\n" + + " public static int foo(int i) throws MyException {\n" + + " int v = -1;\n" + + " try {\n" + + " v = switch (i) {\n" + + " case 0 -> switch(i) {\n" + + " case 0 -> 1;\n" + + " default -> throw new MyException();\n" + + " };\n" + + " default -> 1;\n" + + " };\n" + + " } finally {\n" + + " // do nothing\n" + + " }\n" + + " return v;\n" + + " } \n" + + " public static void main(String argv[]) {\n" + + " try {\n" + + " System.out.println(X.foo(0));\n" + + " } catch (MyException e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "}\n" + + "class MyException extends Exception {\n" + + " private static final long serialVersionUID = 3461899582505930473L; \n" + + "}" + }, + "1"); + } + public void testBug544943_2() { + runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " @SuppressWarnings({ \"preview\" })\n" + + " public static int foo(int i) throws Exception {\n" + + " int v = switch (i) {\n" + + " case 0 -> switch (i) {\n" + + " case 0 -> 0;\n" + + " default-> throw new Exception();\n" + + " case 3 -> 3;\n" + + " case 2 -> throw new Exception();\n" + + " };\n" + + " default -> 0;\n" + + " };\n" + + " return v;\n" + + " }\n" + + " public static void main(String argv[]) throws Exception {\n" + + " System.out.println(X.foo(1));\n" + + " }\n" + + "}" + }, + "0"); + } }
\ No newline at end of file |