Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-10-30 08:51:49 +0000
committerManoj Palat2020-10-30 14:20:13 +0000
commitf396d6ad6a7349563fdb58976ed54285bfa0fdb6 (patch)
treed3ed8ebbc2d67e48281ed643cb60cc3a7fbe3f91
parentf1c0f2f95158ce4f2e31aa227426aaeeb02164b8 (diff)
downloadeclipse.jdt.core-I20201030-1800.tar.gz
eclipse.jdt.core-I20201030-1800.tar.xz
eclipse.jdt.core-I20201030-1800.zip
Bug 566979 - No Syntax error seen: when "sealed" token used inI20201030-1800
method signature Change-Id: I5bfb48ab285697caaa69bc826d65cddcfea442d6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java111
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java2
3 files changed, 112 insertions, 7 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
index e3c6a1b251..c93f4657e6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
@@ -2378,7 +2378,7 @@ public void testBug558718_001() {
"1. ERROR in X.java (at line 1)\n" +
" record R() {}\n" +
" ^^^^^^\n" +
- "Records is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "Syntax error on token \"record\", record expected\n" +
"----------\n",
null,
true,
@@ -2399,7 +2399,7 @@ public void testBug558718_002() {
"1. ERROR in X.java (at line 1)\n" +
" record R() {}\n" +
" ^^^^^^\n" +
- "The preview feature Records is only available with source level 15 and above\n" +
+ "Syntax error on token \"record\", @ expected\n" +
"----------\n" +
"2. ERROR in X.java (at line 1)\n" +
" record R() {}\n" +
@@ -6870,7 +6870,7 @@ public void testBug564672b_039() {
"1. ERROR in X.java (at line 1)\n" +
" record Point(record x, int i) { }\n" +
" ^^^^^^\n" +
- "Records is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "Syntax error on token \"record\", record expected\n" +
"----------\n" +
"2. WARNING in X.java (at line 7)\n" +
" class record {}\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java
index 809d744db6..64095ac847 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java
@@ -31,7 +31,7 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 {
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug565847_001"};
+// TESTS_NAMES = new String[] { "testBug566979","testBug566980", "testBug566846"};
}
public static Class<?> testClass() {
@@ -2847,7 +2847,7 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 {
"1. ERROR in X.java (at line 1)\n" +
" record X(permits p) {\n" +
" ^^^^^^\n" +
- "Records is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "Syntax error on token \"record\", record expected\n" +
"----------\n",
null,
true,
@@ -4570,7 +4570,7 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 {
"1. ERROR in X.java (at line 1)\n" +
" record X(sealed p) {\n" +
" ^^^^^^\n" +
- "Records is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "Syntax error on token \"record\", record expected\n" +
"----------\n",
null,
true,
@@ -5305,4 +5305,109 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 {
options
);
}
+ @SuppressWarnings({ "rawtypes" })
+ public void testBug566979_001() {
+ Map options = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public sealed void main(String[] args){ }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public sealed void main(String[] args){ }\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"sealed\", static expected\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug566979_002() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public sealed void main(String[] args){ }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public sealed void main(String[] args){ }\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"sealed\", static expected\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ @SuppressWarnings({ "rawtypes" })
+ public void testBug566980_001() {
+ Map options = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public permits void main(String[] args){ }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public permits void main(String[] args){ }\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"void\", delete this token\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug566980_002() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public permits void main(String[] args){ }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public permits void main(String[] args){ }\n" +
+ " ^^^^\n" +
+ "Syntax error on token \"void\", delete this token\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ @SuppressWarnings({ "rawtypes" })
+ public void testBug566846_001() {
+ Map options = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X;\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " record X;\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"record\", package expected\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 1956d732b6..57044ac84e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -9541,7 +9541,7 @@ public boolean validateRestrictedKeywords(char[] name, int start, int end, boole
for (char[] k : restrictedKeywords) {
if (CharOperation.equals(name, k)) {
if (reportSyntaxError) {
- return validateJavaFeatureSupport(feature, start, end);
+// return validateJavaFeatureSupport(feature, start, end);
} else {
if (feature.isPreview()) {
int severity = isPreviewEnabled ? ProblemSeverities.Error | ProblemSeverities.Fatal : ProblemSeverities.Warning;

Back to the top