Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2021-05-28 09:13:16 +0000
committerJay Arthanareeswaran2021-06-01 03:06:20 +0000
commitfc6809fc8df20391ad2b0b78c6bd3dafc021bc1c (patch)
treea69cbcfb23b9f73c499b2fc6bbc4afdd1c3b55be
parente120bd98cc07340c096c028086c794c9f3d39927 (diff)
downloadeclipse.jdt.core-fc6809fc8df20391ad2b0b78c6bd3dafc021bc1c.tar.gz
eclipse.jdt.core-fc6809fc8df20391ad2b0b78c6bd3dafc021bc1c.tar.xz
eclipse.jdt.core-fc6809fc8df20391ad2b0b78c6bd3dafc021bc1c.zip
Bug 573310 - [17][sealed] Promote Sealed Classes to Standard Feature
Change-Id: If935c65566a36b518d069a0908e1a4c41cb69ab0 Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/181132 Tested-by: JDT Bot <jdt-bot@eclipse.org>
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/SealedTypeElementsTests.java14
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java4
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java407
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java14
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_1.java8
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SealedTypeModelTests.java14
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java17
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java32
10 files changed, 130 insertions, 386 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/SealedTypeElementsTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/SealedTypeElementsTests.java
index 2757b85737..1f6d15ea58 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/SealedTypeElementsTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/SealedTypeElementsTests.java
@@ -32,7 +32,7 @@ public class SealedTypeElementsTests extends TestCase {
public void test001() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test001", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test001", null, "sealed", false);
}
public void test001Javac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -40,7 +40,7 @@ public class SealedTypeElementsTests extends TestCase {
}
public void test002() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test002", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test002", null, "sealed", false);
}
public void test002Javac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -48,7 +48,7 @@ public class SealedTypeElementsTests extends TestCase {
}
public void test003() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test003", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test003", null, "sealed", false);
}
public void test003Javac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -56,7 +56,7 @@ public class SealedTypeElementsTests extends TestCase {
}
public void test004() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test004", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test004", null, "sealed", false);
}
public void test004Javac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -64,7 +64,7 @@ public class SealedTypeElementsTests extends TestCase {
}
public void test005Src() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test005Src", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test005Src", null, "sealed", false);
}
public void test005SrcJavac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -72,7 +72,7 @@ public class SealedTypeElementsTests extends TestCase {
}
public void test005Binary() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test005Binary", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test005Binary", null, "sealed", false);
}
public void test005BinaryJavac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
@@ -80,7 +80,7 @@ public class SealedTypeElementsTests extends TestCase {
}
public void test006() throws IOException {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithPreview(compiler, MODULE_PROC, "17", "test006", null, "sealed", true);
+ internalTestWithPreview(compiler, MODULE_PROC, "17", "test006", null, "sealed", false);
}
public void test006Javac() throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java
index 2bae0e37a6..4044835051 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1735,7 +1735,7 @@ public class JavadocTest_1_5 extends JavadocTest {
* Bug 86769: [javadoc] Warn/Error for 'Missing javadoc comments' doesn't recognize private inner classes
* @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=86769"
*/
- public void testBug86769() {
+ public void _testBug86769() {
this.reportMissingJavadocComments = CompilerOptions.ERROR;
runNegativeTest(
new String[] {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
index 9572760051..a0e437ce01 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
@@ -51,10 +51,9 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
// Enables the tests to run individually
protected Map<String, String> getCompilerOptions() {
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_17); // FIXME
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_17);
defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_17);
defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_17);
- defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
defaultOptions.put(CompilerOptions.OPTION_Store_Annotations, CompilerOptions.ENABLED);
return defaultOptions;
@@ -1690,7 +1689,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1746,7 +1745,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
},
"----------\n" +
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" permits p;\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1757,7 +1756,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"The method Zork() is undefined for the type X\n" +
"----------\n" +
"----------\n" +
- "1. WARNING in permits.java (at line 1)\n" +
+ "1. ERROR in permits.java (at line 1)\n" +
" public class permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1813,7 +1812,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X<permits> {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1895,7 +1894,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X extends permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1905,7 +1904,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "3. WARNING in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" class permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1960,7 +1959,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X implements permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -1970,7 +1969,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "3. WARNING in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" interface permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -2025,7 +2024,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" interface X extends permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -2035,7 +2034,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "3. WARNING in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" interface permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -2088,16 +2087,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" permits foo() {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " permits foo() {\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -2144,16 +2138,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" void foo() throws permits{\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " void foo() throws permits{\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -2215,16 +2204,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X <T extends permits>{\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 1)\n" +
- " class X <T extends permits>{\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 1)\n" +
" class X <T extends permits>{\n" +
" ^\n" +
@@ -2290,16 +2274,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" private final permits p;\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " private final permits p;\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 5)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -2359,16 +2338,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^^^^^^^^^^\n" +
"This lambda expression refers to the missing type permits\n" +
"----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
+ "2. ERROR in X.java (at line 3)\n" +
" I i = (permits p)-> {};\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "3. ERROR in X.java (at line 3)\n" +
- " I i = (permits p)-> {};\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"4. ERROR in X.java (at line 4)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -2406,15 +2380,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" public void foo(permits this) {}\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " public void foo(permits this) {}\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -2448,15 +2417,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" public void foo(permits this) {}\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " public void foo(permits this) {}\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -2499,12 +2463,12 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" class permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
+ "2. ERROR in X.java (at line 3)\n" +
" public void foo(permits this) {}\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -2552,16 +2516,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" permits p;\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " permits p;\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 4)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -2614,16 +2573,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" for (permits i = 0; i < 10; ++i) {} \n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " for (permits i = 0; i < 10; ++i) {} \n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 6)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -2670,25 +2624,15 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" public static void main(permits[] args) {\n" +
" ^^^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " public static void main(permits[] args) {\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 3)\n" +
+ "3. ERROR in X.java (at line 3)\n" +
" for (permits p : args) {} \n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "4. ERROR in X.java (at line 3)\n" +
- " for (permits p : args) {} \n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -2746,15 +2690,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" try (permits y = new Y()) {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " try (permits y = new Y()) {\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -2812,15 +2751,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" } catch (permits e) {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " } catch (permits e) {\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -2862,15 +2796,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^\n" +
"permits cannot be resolved to a type\n" +
"----------\n" +
- "2. WARNING in X.java (at line 1)\n" +
+ "2. ERROR in X.java (at line 1)\n" +
" record X(permits p) {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 17\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 1)\n" +
- " record X(permits p) {\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -2917,16 +2846,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" <permits>this(t);\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " <permits>this(t);\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 5)\n" +
" <permits>this(t);\n" +
" ^^^^^^^^\n" +
@@ -2984,15 +2908,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^^^^^^^^^^^^^^\n" +
"The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" +
"----------\n" +
- "2. WARNING in X.java (at line 5)\n" +
+ "2. ERROR in X.java (at line 5)\n" +
" new <permits>X(t).foo();\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 5)\n" +
- " new <permits>X(t).foo();\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -3041,16 +2960,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 6)\n" +
+ "1. ERROR in X.java (at line 6)\n" +
" x.<permits>foo(0);\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 6)\n" +
- " x.<permits>foo(0);\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 6)\n" +
" x.<permits>foo(0);\n" +
" ^^^\n" +
@@ -3096,15 +3010,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" X x = new permits();\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " X x = new permits();\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -3161,7 +3070,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" new permits() {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3171,7 +3080,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type new permits(){}\n" +
"----------\n" +
- "3. WARNING in X.java (at line 11)\n" +
+ "3. ERROR in X.java (at line 11)\n" +
" abstract class permits {\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3212,15 +3121,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" Object[] p = new permits[10];\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " Object[] p = new permits[10];\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -3275,25 +3179,15 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^\n" +
"The method foo(permits) from the type X refers to the missing type permits\n" +
"----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
+ "2. ERROR in X.java (at line 3)\n" +
" new X().foo((permits) null);\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "3. ERROR in X.java (at line 3)\n" +
- " new X().foo((permits) null);\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 5)\n" +
+ "4. ERROR in X.java (at line 5)\n" +
" private void foo(permits o) {}\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "5. ERROR in X.java (at line 5)\n" +
- " private void foo(permits o) {}\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -3331,15 +3225,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" if (o instanceof permits) {}\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " if (o instanceof permits) {}\n" +
- " ^^^^^^^\n" +
- "permits cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -3399,7 +3288,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "2. WARNING in X.java (at line 8)\n" +
+ "2. ERROR in X.java (at line 8)\n" +
" class permits{}\n" +
" ^^^^^^^\n" +
"\'permits\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3423,7 +3312,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3479,7 +3368,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
},
"----------\n" +
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" sealed p;\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3490,7 +3379,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"The method Zork() is undefined for the type X\n" +
"----------\n" +
"----------\n" +
- "1. WARNING in sealed.java (at line 1)\n" +
+ "1. ERROR in sealed.java (at line 1)\n" +
" public class sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3546,7 +3435,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X<sealed> {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3628,7 +3517,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X extends sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3638,7 +3527,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "3. WARNING in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" class sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3693,7 +3582,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X implements sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3703,7 +3592,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "3. WARNING in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" interface sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3758,7 +3647,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" interface X extends sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3768,7 +3657,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "3. WARNING in X.java (at line 6)\n" +
+ "3. ERROR in X.java (at line 6)\n" +
" interface sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -3821,16 +3710,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" sealed foo() {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " sealed foo() {\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -3877,16 +3761,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" void foo() throws sealed{\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " void foo() throws sealed{\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -3948,16 +3827,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
+ "1. ERROR in X.java (at line 1)\n" +
" class X <T extends sealed>{\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 1)\n" +
- " class X <T extends sealed>{\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 1)\n" +
" class X <T extends sealed>{\n" +
" ^\n" +
@@ -4023,16 +3897,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" private final sealed p;\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " private final sealed p;\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 5)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -4092,16 +3961,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^^^^^^^^^\n" +
"This lambda expression refers to the missing type sealed\n" +
"----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
+ "2. ERROR in X.java (at line 3)\n" +
" I i = (sealed p)-> {};\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "3. ERROR in X.java (at line 3)\n" +
- " I i = (sealed p)-> {};\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"4. ERROR in X.java (at line 4)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -4139,15 +4003,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" public void foo(sealed this) {}\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " public void foo(sealed this) {}\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4181,15 +4040,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" public void foo(sealed this) {}\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " public void foo(sealed this) {}\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4232,12 +4086,12 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" class sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
+ "2. ERROR in X.java (at line 3)\n" +
" public void foo(sealed this) {}\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -4285,16 +4139,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" sealed p;\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " sealed p;\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 4)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -4347,16 +4196,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" for (sealed i = 0; i < 10; ++i) {} \n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " for (sealed i = 0; i < 10; ++i) {} \n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 6)\n" +
" Zork();\n" +
" ^^^^\n" +
@@ -4403,25 +4247,15 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
+ "1. ERROR in X.java (at line 2)\n" +
" public static void main(sealed[] args) {\n" +
" ^^^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 2)\n" +
- " public static void main(sealed[] args) {\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 3)\n" +
+ "3. ERROR in X.java (at line 3)\n" +
" for (sealed p : args) {} \n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "4. ERROR in X.java (at line 3)\n" +
- " for (sealed p : args) {} \n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4479,15 +4313,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" try (sealed y = new Y()) {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " try (sealed y = new Y()) {\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4545,15 +4374,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" } catch (sealed e) {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " } catch (sealed e) {\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4595,15 +4419,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^\n" +
"sealed cannot be resolved to a type\n" +
"----------\n" +
- "2. WARNING in X.java (at line 1)\n" +
+ "2. ERROR in X.java (at line 1)\n" +
" record X(sealed p) {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 17\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 1)\n" +
- " record X(sealed p) {\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4650,16 +4469,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" <sealed>this(t);\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " <sealed>this(t);\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 5)\n" +
" <sealed>this(t);\n" +
" ^^^^^^^^\n" +
@@ -4717,15 +4531,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^^^^^^^^^^^^^\n" +
"The parameterized constructor <sealed>X(sealed) of type X is not applicable for the arguments (Integer)\n" +
"----------\n" +
- "2. WARNING in X.java (at line 5)\n" +
+ "2. ERROR in X.java (at line 5)\n" +
" new <sealed>X(t).foo();\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 5)\n" +
- " new <sealed>X(t).foo();\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4774,16 +4583,11 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 6)\n" +
+ "1. ERROR in X.java (at line 6)\n" +
" x.<sealed>foo(0);\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "2. ERROR in X.java (at line 6)\n" +
- " x.<sealed>foo(0);\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
"3. ERROR in X.java (at line 6)\n" +
" x.<sealed>foo(0);\n" +
" ^^^\n" +
@@ -4829,15 +4633,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" X x = new sealed();\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " X x = new sealed();\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -4894,7 +4693,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" new sealed() {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -4904,7 +4703,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type new sealed(){}\n" +
"----------\n" +
- "3. WARNING in X.java (at line 11)\n" +
+ "3. ERROR in X.java (at line 11)\n" +
" abstract class sealed {\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -4945,15 +4744,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" Object[] p = new sealed[10];\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " Object[] p = new sealed[10];\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -5008,25 +4802,15 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^\n" +
"The method foo(sealed) from the type X refers to the missing type sealed\n" +
"----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
+ "2. ERROR in X.java (at line 3)\n" +
" new X().foo((sealed) null);\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
"----------\n" +
- "3. ERROR in X.java (at line 3)\n" +
- " new X().foo((sealed) null);\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 5)\n" +
+ "4. ERROR in X.java (at line 5)\n" +
" private void foo(sealed o) {}\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "5. ERROR in X.java (at line 5)\n" +
- " private void foo(sealed o) {}\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -5064,15 +4848,10 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" if (o instanceof sealed) {}\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " if (o instanceof sealed) {}\n" +
- " ^^^^^^\n" +
- "sealed cannot be resolved to a type\n" +
"----------\n",
null,
true,
@@ -5132,7 +4911,7 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
" ^^^^\n" +
"The method Zork() is undefined for the type X\n" +
"----------\n" +
- "2. WARNING in X.java (at line 8)\n" +
+ "2. ERROR in X.java (at line 8)\n" +
" class sealed{}\n" +
" ^^^^^^\n" +
"\'sealed\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +"\n" +
@@ -5308,31 +5087,16 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"final class Z implements I{}",
},
"----------\n" +
- "1. WARNING in X.java (at line 1)\n" +
- " public sealed class X permits Y {Zork();\n" +
- " ^^^^^^\n" +
- "You are using a preview language feature that may or may not be supported in a future release\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 1)\n" +
- " public sealed class X permits Y {Zork();\n" +
- " ^^^^^^^\n" +
- "You are using a preview language feature that may or may not be supported in a future release\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 1)\n" +
- " public sealed class X permits Y {Zork();\n" +
- " ^^^^^^\n" +
- "Return type for the method is missing\n" +
- "----------\n" +
- "4. ERROR in X.java (at line 1)\n" +
- " public sealed class X permits Y {Zork();\n" +
- " ^^^^^^\n" +
- "This method requires a body instead of a semicolon\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 4)\n" +
- " sealed interface I{}\n" +
- " ^^^^^^\n" +
- "You are using a preview language feature that may or may not be supported in a future release\n" +
- "----------\n",
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits Y {Zork();\n" +
+ " ^^^^^^\n" +
+ "Return type for the method is missing\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits Y {Zork();\n" +
+ " ^^^^^^\n" +
+ "This method requires a body instead of a semicolon\n" +
+ "----------\n",
null,
true,
options
@@ -5570,7 +5334,6 @@ public class SealedTypesTests extends AbstractRegressionTest9 {
"X.java",
"import java.lang.reflect.Modifier;\n"+
"\n"+
- "@SuppressWarnings(\"preview\")\n"+
"sealed interface I {\n"+
" void foo();\n"+
"}\n"+
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
index 36295bba49..92655ba3d6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
@@ -2174,6 +2174,12 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_16);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_16);
javaProject.setOptions(options);
+ } else if ("17".equals(compliance)) {
+ Map options = new HashMap();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_17);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_17);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_17);
+ javaProject.setOptions(options);
}
result[0] = javaProject;
@@ -3460,6 +3466,14 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
new IPath[] {getExternalJCLPath("14"), getExternalJCLSourcePath("14"), getExternalJCLRootSourcePath()},
null);
}
+ } else if ("17".equals(compliance)) {
+ if (JavaCore.getClasspathVariable("JCL14_LIB") == null) {
+ setupExternalJCL("jclMin14");
+ JavaCore.setClasspathVariables(
+ new String[] {"JCL14_LIB", "JCL14_SRC", "JCL_SRCROOT"},
+ new IPath[] {getExternalJCLPath("14"), getExternalJCLSourcePath("14"), getExternalJCLRootSourcePath()},
+ null);
+ }
} else {
if (JavaCore.getClasspathVariable("JCL_LIB") == null) {
setupExternalJCL("jclMin");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_1.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_1.java
index 0e3eca7e15..8c509b16b2 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_1.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests16_1.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2020 IBM Corporation and others.
+ * Copyright (c) 2020, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,11 +31,11 @@ public class CompletionTests16_1 extends AbstractJavaModelCompletionTests {
public void setUpSuite() throws Exception {
if (COMPLETION_PROJECT == null) {
- COMPLETION_PROJECT = setUpJavaProject("Completion", "16");
+ COMPLETION_PROJECT = setUpJavaProject("Completion", "17");
} else {
- setUpProjectCompliance(COMPLETION_PROJECT, "16");
+ setUpProjectCompliance(COMPLETION_PROJECT, "17");
}
- COMPLETION_PROJECT.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ COMPLETION_PROJECT.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.DISABLED);
super.setUpSuite();
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SealedTypeModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SealedTypeModelTests.java
index 243c87464e..a9a9aceef5 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SealedTypeModelTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SealedTypeModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2020 IBM Corporation.
+ * Copyright (c) 2020, 2021 IBM Corporation.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -53,11 +53,10 @@ public class SealedTypeModelTests extends AbstractJavaModelTests {
};
}
public static Test suite() {
- return buildModelTestSuite(AbstractCompilerTest.F_15, SealedTypeModelTests.class);
+ return buildModelTestSuite(AbstractCompilerTest.F_17, SealedTypeModelTests.class);
}
protected IJavaProject createJavaProject(String projectName) throws CoreException {
- IJavaProject createJavaProject = super.createJavaProject(projectName, new String[] {"src"}, new String[] {"JCL14_LIB"}, "bin", "15");
- createJavaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ IJavaProject createJavaProject = super.createJavaProject(projectName, new String[] {"src"}, new String[] {"JCL14_LIB"}, "bin", "17");
return createJavaProject;
}
// Check types with neither sealed nor non-sealed don't return those modifiers
@@ -65,8 +64,7 @@ public class SealedTypeModelTests extends AbstractJavaModelTests {
try {
IJavaProject project = createJavaProject("SealedTypes");
project.open(null);
- String fileContent = "@SuppressWarnings(\"preview\")\n" +
- "interface I {}\n" +
+ String fileContent = "interface I {}\n" +
"public class X implements I {}\n" +
"interface Y extends I {}\n";
@@ -178,7 +176,7 @@ public class SealedTypeModelTests extends AbstractJavaModelTests {
String outputDirectory = Util.getOutputDirectory();
String jarPath = outputDirectory + File.separator + "sealed.jar";
- Util.createJar(sources, jarPath, "15", true);
+ Util.createJar(sources, jarPath, "17", true);
IJavaProject project = createJavaProject("SealedTypes");
addClasspathEntry(project, JavaCore.newLibraryEntry(new Path(jarPath), null, null, null, null, false));
@@ -239,7 +237,7 @@ public class SealedTypeModelTests extends AbstractJavaModelTests {
String outputDirectory = Util.getOutputDirectory();
String jarPath = outputDirectory + File.separator + "sealed.jar";
- Util.createJar(sources, jarPath, "15", true);
+ Util.createJar(sources, jarPath, "17", true);
IJavaProject project = createJavaProject("SealedTypes");
addClasspathEntry(project, JavaCore.newLibraryEntry(new Path(jarPath), null, null, null, null, false));
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index c96e227508..55c810e22f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -2259,7 +2259,7 @@ private void classHeaderExtendsOrImplements(boolean isInterface, boolean isRecor
}
keywords[count++] = Keywords.IMPLEMENTS;
}
- if (this.options.enablePreviewFeatures) {
+ if (JavaFeature.SEALED_CLASSES.isSupported(this.options)) {
boolean sealed = (type.modifiers & ExtraCompilerModifiers.AccSealed) != 0;
if (sealed)
keywords[count++] = RestrictedIdentifiers.PERMITS;
@@ -2600,7 +2600,7 @@ protected void consumeClassHeaderExtends() {
if(type.superInterfaces == null) {
keywords[count++] = Keywords.IMPLEMENTS;
}
- if (this.options.enablePreviewFeatures) {
+ if (JavaFeature.SEALED_CLASSES.isSupported(this.options)) {
boolean sealed = (type.modifiers & ExtraCompilerModifiers.AccSealed) != 0;
if (sealed)
keywords[count++] = RestrictedIdentifiers.PERMITS;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
index 1f52f9cd8e..d24d23bad6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
@@ -55,7 +55,7 @@ public enum JavaFeature {
SEALED_CLASSES(ClassFileConstants.JDK17,
Messages.bind(Messages.sealed_types),
new char[][] {TypeConstants.SEALED, TypeConstants.PERMITS},
- true),
+ false),
;
final long compliance;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 31bb9656ca..528295c3aa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -53,6 +53,8 @@ import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.JavaFeature;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
@@ -143,8 +145,7 @@ public class ClassScope extends Scope {
}
private void checkForEnumSealedPreview(ReferenceBinding supertype, LocalTypeBinding anonymousType) {
- if (compilerOptions().sourceLevel < ClassFileConstants.JDK15
- || !compilerOptions().enablePreviewFeatures
+ if (!JavaFeature.SEALED_CLASSES.isSupported(compilerOptions())
|| !supertype.isEnum()
|| !(supertype instanceof SourceTypeBinding))
return;
@@ -585,10 +586,10 @@ public class ClassScope extends Scope {
private void checkAndSetModifiers() {
SourceTypeBinding sourceType = this.referenceContext.binding;
int modifiers = sourceType.modifiers;
- boolean isPreviewEnabled = compilerOptions().sourceLevel == ClassFileConstants.getLatestJDKLevel() &&
- compilerOptions().enablePreviewFeatures;
+ CompilerOptions options = compilerOptions();
boolean is16Plus = compilerOptions().sourceLevel >= ClassFileConstants.JDK16;
- boolean flagSealedNonModifiers = isPreviewEnabled &&
+ boolean isSealedSupported = JavaFeature.SEALED_CLASSES.isSupported(options);
+ boolean flagSealedNonModifiers = isSealedSupported &&
(modifiers & (ExtraCompilerModifiers.AccSealed | ExtraCompilerModifiers.AccNonSealed)) != 0;
if (sourceType.isRecord()) {
/* JLS 14 Records Sec 8.10 - A record declaration is implicitly final. */
@@ -725,7 +726,7 @@ public class ClassScope extends Scope {
| ClassFileConstants.AccStrictfp | ClassFileConstants.AccAnnotation
| ((is16Plus && this.parent instanceof ClassScope) ? ClassFileConstants.AccStatic : 0));
if ((realModifiers & UNEXPECTED_MODIFIERS) != 0
- || (isPreviewEnabled && flagSealedNonModifiers))
+ || flagSealedNonModifiers)
problemReporter().localStaticsIllegalVisibilityModifierForInterfaceLocalType(sourceType);
// if ((modifiers & ClassFileConstants.AccStatic) != 0) {
// problemReporter().recordIllegalStaticModifierForLocalClassOrInterface(sourceType);
@@ -820,7 +821,7 @@ public class ClassScope extends Scope {
}
modifiers |= ClassFileConstants.AccFinal;
}
- if (isPreviewEnabled && (modifiers & ClassFileConstants.AccFinal) == 0)
+ if (isSealedSupported && (modifiers & ClassFileConstants.AccFinal) == 0)
modifiers |= ExtraCompilerModifiers.AccSealed;
}
} else if (sourceType.isRecord()) {
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 0fe6ee9655..638a52d5a9 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
@@ -11967,8 +11967,6 @@ public void illegalModifierForLocalEnumDeclaration(SourceTypeBinding type) {
type.sourceEnd());
}
private void sealedMissingModifier(int problem, SourceTypeBinding type, TypeDeclaration typeDecl, TypeBinding superTypeBinding) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
@@ -11988,8 +11986,6 @@ public void sealedMissingInterfaceModifier(SourceTypeBinding type, TypeDeclarati
sealedMissingModifier(IProblem.SealedMissingInterfaceModifier, type, typeDecl, superTypeBinding);
}
public void sealedDisAllowedNonSealedModifierInClass(SourceTypeBinding type, TypeDeclaration typeDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
this.handle(
IProblem.SealedDisAllowedNonSealedModifierInClass,
@@ -12000,8 +11996,6 @@ public void sealedDisAllowedNonSealedModifierInClass(SourceTypeBinding type, Typ
}
private void sealedSuperTypeDoesNotPermit(int problem, SourceTypeBinding type, TypeReference superType, TypeBinding superTypeBinding) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
@@ -12018,8 +12012,6 @@ public void sealedSuperClassDoesNotPermit(SourceTypeBinding type, TypeReference
sealedSuperTypeDoesNotPermit(IProblem.SealedSuperClassDoesNotPermit, type, superType, superTypeBinding);
}
public void sealedSuperInterfaceDoesNotPermit(SourceTypeBinding type, TypeReference superType, TypeBinding superTypeBinding) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
@@ -12034,16 +12026,12 @@ public void sealedSuperInterfaceDoesNotPermit(SourceTypeBinding type, TypeRefere
}
public void sealedMissingSealedModifier(SourceTypeBinding type, ASTNode node) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
this.handle(IProblem.SealedMissingSealedModifier, new String[] { name }, new String[] { name }, node.sourceStart,
node.sourceEnd);
}
public void sealedDuplicateTypeInPermits(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.SealedDuplicateTypeInPermits,
new String[] {
@@ -12057,8 +12045,6 @@ public void sealedDuplicateTypeInPermits(SourceTypeBinding type, TypeReference r
}
public void sealedNotDirectSuperClass(ReferenceBinding type, TypeReference reference, SourceTypeBinding superType) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.SealedNotDirectSuperClass,
new String[] {
@@ -12071,8 +12057,6 @@ public void sealedNotDirectSuperClass(ReferenceBinding type, TypeReference refer
reference.sourceEnd);
}
public void sealedPermittedTypeOutsideOfModule(ReferenceBinding permType, SourceTypeBinding type, ASTNode node, ModuleBinding moduleBinding) {
- if (!this.options.enablePreviewFeatures)
- return;
String permTypeName = new String(permType.sourceName);
String name = new String(type.sourceName());
String moduleName = new String(moduleBinding.name());
@@ -12084,16 +12068,12 @@ public void sealedPermittedTypeOutsideOfModule(ReferenceBinding permType, Source
node.sourceEnd);
}
public void sealedPermittedTypeOutsideOfModule(SourceTypeBinding type, ASTNode node) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
this.handle(IProblem.SealedPermittedTypeOutsideOfModule, new String[] { name }, new String[] { name },
node.sourceStart, node.sourceEnd);
}
public void sealedPermittedTypeOutsideOfPackage(ReferenceBinding permType, SourceTypeBinding type, ASTNode node, PackageBinding packageBinding) {
- if (!this.options.enablePreviewFeatures)
- return;
String permTypeName = new String(permType.sourceName);
String name = new String(type.sourceName());
String packageName = packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? "default" : //$NON-NLS-1$
@@ -12107,16 +12087,12 @@ public void sealedPermittedTypeOutsideOfPackage(ReferenceBinding permType, Sourc
}
public void sealedSealedTypeMissingPermits(SourceTypeBinding type, ASTNode node) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
this.handle(IProblem.SealedSealedTypeMissingPermits, new String[] { name }, new String[] { name }, node.sourceStart,
node.sourceEnd);
}
public void sealedInterfaceIsSealedAndNonSealed(SourceTypeBinding type, ASTNode node) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
this.handle(IProblem.SealedInterfaceIsSealedAndNonSealed,
new String[] { name },
@@ -12126,8 +12102,6 @@ public void sealedInterfaceIsSealedAndNonSealed(SourceTypeBinding type, ASTNode
}
public void sealedDisAllowedNonSealedModifierInInterface(SourceTypeBinding type, TypeDeclaration typeDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
this.handle(
IProblem.SealedDisAllowedNonSealedModifierInInterface,
@@ -12138,8 +12112,6 @@ public void sealedDisAllowedNonSealedModifierInInterface(SourceTypeBinding type,
}
public void sealedNotDirectSuperInterface(ReferenceBinding type, TypeReference reference, SourceTypeBinding superType) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.SealedNotDirectSuperInterface,
new String[] {
@@ -12153,8 +12125,6 @@ public void sealedNotDirectSuperInterface(ReferenceBinding type, TypeReference r
}
public void sealedLocalDirectSuperTypeSealed(SourceTypeBinding type, TypeReference superclass, TypeBinding superTypeBinding) {
- if (!this.options.enablePreviewFeatures)
- return;
String name = new String(type.sourceName());
String superTypeFullName = new String(superTypeBinding.readableName());
String superTypeShortName = new String(superTypeBinding.shortReadableName());
@@ -12167,8 +12137,6 @@ public void sealedLocalDirectSuperTypeSealed(SourceTypeBinding type, TypeReferen
superclass.sourceEnd);
}
public void sealedAnonymousClassCannotExtendSealedType(TypeReference reference, TypeBinding type) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.SealedAnonymousClassCannotExtendSealedType,
new String[] {new String(type.readableName())},

Back to the top