Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2019-09-13 10:29:05 +0000
committerJay Arthanareeswaran2019-09-13 19:09:40 +0000
commitc460c48be65e8cf2ed6643996a5d330a23b8b8c8 (patch)
tree4ba73e96d493a395316e35bb5d2b75c73a4effa5
parentc8963395d8433396859f96d77dd4cd1d91512122 (diff)
downloadeclipse.jdt.core-Y20190916-0900.tar.gz
eclipse.jdt.core-Y20190916-0900.tar.xz
eclipse.jdt.core-Y20190916-0900.zip
Bug 551030 - [13] Invalid_Char_In_String: InvalidInputException inY20190916-0900Y20190914-0255
Scanner with yield Change-Id: Ifd51a74d8569affa79d03065c7f6abf30763b1e1 Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java48
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java7
2 files changed, 54 insertions, 1 deletions
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 8ecf027868..cc54aa9756 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
@@ -3436,4 +3436,52 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
},
"1");
}
+ public void testBug551030a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"nls\")\n" +
+ " static final String MONDAY = \"MONDAY\";\n" +
+ " public static void main(String[] args) {\n" +
+ " int num = switch (day) {\n" +
+ " case MONDAY: \n" +
+ " // Nothing\n" +
+ " default:\n" +
+ " yield \"; \n" +
+ " }; \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " yield \"; \n" +
+ " ^^^^^^^\n" +
+ "String literal is not properly closed by a double-quote\n" +
+ "----------\n");
+ }
+ public void testBug551030b() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @SuppressWarnings(\"nls\")\n" +
+ " static final String MONDAY = \"MONDAY\";\n" +
+ " public static void main(String[] args) {\n" +
+ " int num = switch (day) {\n" +
+ " case MONDAY: \n" +
+ " // Nothing\n" +
+ " default:\n" +
+ " yield \"\"\"; \n" +
+ " }; \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " yield \"\"\"; \n" +
+ " ^^^^^^^\n" +
+ "String literal is not properly closed by a double-quote\n" +
+ "----------\n");
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 766e5e5df7..9d4f6b4db9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -5085,7 +5085,12 @@ private boolean disambiguateYieldWithLookAhead() {
default : return true;
}
} catch (InvalidInputException e) {
- e.printStackTrace();
+ if (e.getMessage().equals(INVALID_CHAR_IN_STRING)) {
+ //Ignore
+ } else {
+ // Shouldn't happen, but log the error
+ e.printStackTrace();
+ }
}
return false; // IIE event;
}

Back to the top