Bug 569328 - [16] Promote the relevant features from preview to standard
Change-Id: Ie42c8308e7d780bdafcabfdabadaca7e2f14b944
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForRecord.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForRecord.java
index 9321476..e692365 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForRecord.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForRecord.java
@@ -101,7 +101,7 @@
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_16); // FIXME
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_16);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_16);
- options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
return options;
}
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 7647515..5dcf7b8 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
@@ -65,6 +65,8 @@
@Override
protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
+ if (!isJRE16Plus)
+ return;
Runner runner = new Runner();
runner.testFiles = testFiles;
runner.expectedOutputString = expectedOutput;
@@ -75,7 +77,9 @@
}
@Override
protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
- runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("15"));
+ if (!isJRE16Plus)
+ return;
+ runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.DEFAULT);
}
protected void runWarningTest(String[] testFiles, String expectedCompilerLog) {
runWarningTest(testFiles, expectedCompilerLog, null);
@@ -85,14 +89,15 @@
}
protected void runWarningTest(String[] testFiles, String expectedCompilerLog,
Map<String, String> customOptions, String javacAdditionalTestOptions) {
-
+ if (!isJRE16Plus)
+ return;
Runner runner = new Runner();
runner.testFiles = testFiles;
runner.expectedCompilerLog = expectedCompilerLog;
runner.customOptions = customOptions;
runner.vmArguments = new String[] {"--enable-preview"};
- runner.javacTestOptions = javacAdditionalTestOptions == null ? JavacTestOptions.forReleaseWithPreview("15") :
- JavacTestOptions.forReleaseWithPreview("15", javacAdditionalTestOptions);
+ runner.javacTestOptions = javacAdditionalTestOptions == null ? JavacTestOptions.forReleaseWithPreview("16") :
+ JavacTestOptions.forReleaseWithPreview("16", javacAdditionalTestOptions);
runner.runWarningTest();
}
@@ -116,7 +121,7 @@
runConformTest(
new String[] {
"X.java",
- "class X {\n"+
+ "public class X {\n"+
" public static void main(String[] args){\n"+
" System.out.println(0);\n" +
" }\n"+
@@ -7197,6 +7202,8 @@
);
}
public void testBug565388_001() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
this.runNegativeTest(
new String[] {
"X.java",
@@ -7207,10 +7214,16 @@
" public non-sealed record X() {}\n" +
" ^\n" +
"Illegal modifier for the record X; only public, final and strictfp are permitted\n" +
- "----------\n"
+ "----------\n",
+ null,
+ true,
+ options
);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug565388_002() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
this.runNegativeTest(
new String[] {
"X.java",
@@ -7221,8 +7234,12 @@
" public sealed record X() {}\n" +
" ^\n" +
"Illegal modifier for the record X; only public, final and strictfp are permitted\n" +
- "----------\n"
+ "----------\n",
+ null,
+ true,
+ options
);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug565786_001() throws IOException, ClassFormatException {
runConformTest(
@@ -7667,6 +7684,8 @@
"private final int X$1Bar.x");
}
public void testBug566063_001() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
runConformTest(
new String[] {
"X.java",
@@ -7686,9 +7705,14 @@
" }\n"+
"}"
},
- "ONE");
+ "ONE",
+ options
+ );
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug566063_002() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
runNegativeTest(
new String[] {
"X.java",
@@ -7713,9 +7737,16 @@
" static enum E {\n" +
" ^\n" +
"Illegal modifier for local enum E; no explicit modifier is permitted\n" +
- "----------\n");
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug566063_003() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
runNegativeTest(
new String[] {
"X.java",
@@ -7745,34 +7776,46 @@
" static record Bar(E x) implements I{}\n" +
" ^^^\n" +
"A local class or interface Bar is implicitly static; cannot have explicit static declaration\n" +
- "----------\n");
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug566063_004() {
- runNegativeTest(
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ this.runNegativeTest(
new String[] {
- "X.java",
- "class X {\n"+
- " void bar() throws Exception {\n"+
- " enum E {\n"+
- " ONE,\n"+
- " TWO\n"+
- " }\n"+
- " static interface I {}\n"+
- " record Bar(E x) implements I{}\n"+
- " E e = new Bar(E.ONE).x();\n"+
- " System.out.println(e);\n"+
- " }\n"+
- " public static void main(String[] args) throws Exception {\n"+
- " new X().bar();\n"+
- " }\n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " static interface I {}\n" +
- " ^\n" +
- "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
- "----------\n");
+ "X.java",
+ "class X {\n"+
+ " void bar() throws Exception {\n"+
+ " enum E {\n"+
+ " ONE,\n"+
+ " TWO\n"+
+ " }\n"+
+ " static interface I {}\n"+
+ " record Bar(E x) implements I{}\n"+
+ " E e = new Bar(E.ONE).x();\n"+
+ " System.out.println(e);\n"+
+ " }\n"+
+ " public static void main(String[] args) throws Exception {\n"+
+ " new X().bar();\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " static interface I {}\n" +
+ " ^\n" +
+ "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testBug566418_001() {
@@ -7928,6 +7971,8 @@
"----------\n");
}
public void testBug567731_001() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
this.runNegativeTest(
new String[] {
"X.java",
@@ -7948,10 +7993,16 @@
" sealed record B() { } \n" +
" ^\n" +
"Illegal modifier for the local record B; only final and strictfp are permitted\n" +
- "----------\n"
+ "----------\n",
+ null,
+ true,
+ options
);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug567731_002() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
this.runNegativeTest(
new String[] {
"X.java",
@@ -7972,8 +8023,12 @@
" non-sealed record R2() { } \n" +
" ^^\n" +
"Illegal modifier for the local record R2; only final and strictfp are permitted\n" +
- "----------\n"
+ "----------\n",
+ null,
+ true,
+ options
);
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
}
public void testBug566846_1() {
runNegativeTest(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
index ced4bcf..55a127f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
@@ -202,7 +202,7 @@
int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
for (int[] map : complianceTestLevelMapping) {
if ((complianceLevels & map[0]) != 0) {
- long complianceLevelForJavaVersion = ClassFileConstants.getComplianceLevelForJavaVersion(map[0]);
+ long complianceLevelForJavaVersion = ClassFileConstants.getComplianceLevelForJavaVersion(map[1]);
checkCompliance(evaluationTestClass, minimalCompliance, suite, complianceLevels, map[0], map[1], getVersionString(complianceLevelForJavaVersion));
}
}
@@ -652,7 +652,7 @@
}
protected static String getVersionString(long compliance) {
- String version = "version 15 : 59.0";
+ String version = "version 16 : 60.0";
if (compliance < ClassFileConstants.JDK9) return "version 1.8 : 52.0";
if (compliance == ClassFileConstants.JDK9) return "version 9 : 53.0";
if (compliance == ClassFileConstants.JDK10) return "version 10 : 54.0";
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java
index 96c3452..89d84ae 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java
@@ -516,6 +516,7 @@
c = input.read();
}
} catch(IOException ioEx) {
+ ioEx.printStackTrace();
}
}
});
@@ -530,12 +531,14 @@
c = errorStream.read();
}
} catch(IOException ioEx) {
+ ioEx.printStackTrace();
}
}
});
outputThread.start();
errorThread.start();
} catch(TargetException e) {
+ e.printStackTrace();
throw new Error(e.getMessage());
}
@@ -559,6 +562,7 @@
}
} while (this.socket == null && isVMRunning);
} catch (IOException e) {
+ e.printStackTrace();
throw new Error(e.getMessage());
}
}
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 1f8d08a..6517474 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
@@ -11611,8 +11611,6 @@
statement.sourceEnd);
}
public void illegalModifierForLocalRecord(SourceTypeBinding type) {
- if (!this.options.enablePreviewFeatures)
- return;
String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.RecordIllegalModifierForLocalRecord,
@@ -11622,8 +11620,6 @@
type.sourceEnd());
}
public void illegalModifierForInnerRecord(SourceTypeBinding type) {
- if (!this.options.enablePreviewFeatures)
- return;
String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.RecordIllegalModifierForInnerRecord,
@@ -11633,8 +11629,6 @@
type.sourceEnd());
}
public void illegalModifierForRecord(SourceTypeBinding type) {
- if (!this.options.enablePreviewFeatures)
- return;
String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.RecordIllegalModifierForRecord,
@@ -11644,8 +11638,6 @@
type.sourceEnd());
}
public void recordNonStaticFieldDeclarationInRecord(FieldDeclaration field) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordNonStaticFieldDeclarationInRecord,
new String[] { new String(field.name) },
@@ -11654,8 +11646,6 @@
field.sourceEnd);
}
public void recordAccessorMethodHasThrowsClause(ASTNode methodDeclaration) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordAccessorMethodHasThrowsClause,
NoArgument,
@@ -11664,8 +11654,6 @@
methodDeclaration.sourceEnd);
}
public void recordCanonicalConstructorVisibilityReduced(AbstractMethodDeclaration methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCanonicalConstructorVisibilityReduced,
new String[] {
@@ -11678,8 +11666,6 @@
methodDecl.sourceEnd);
}
public void recordCompactConstructorHasReturnStatement(ReturnStatement stmt) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCompactConstructorHasReturnStatement,
NoArgument,
@@ -11688,8 +11674,6 @@
stmt.sourceEnd);
}
public void recordIllegalComponentNameInRecord(RecordComponent recComp, TypeDeclaration typeDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordIllegalComponentNameInRecord,
new String[] {
@@ -11702,8 +11686,6 @@
recComp.sourceEnd);
}
public void recordDuplicateComponent(RecordComponent recordComponent) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordDuplicateComponent,
new String[] { new String(recordComponent.name)},
@@ -11712,8 +11694,6 @@
recordComponent.sourceEnd);
}
public void recordIllegalNativeModifierInRecord(AbstractMethodDeclaration method) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordIllegalNativeModifierInRecord,
new String[] { new String(method.selector)},
@@ -11722,8 +11702,6 @@
method.sourceEnd);
}
public void recordInstanceInitializerBlockInRecord(Initializer initializer) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordInstanceInitializerBlockInRecord,
NoArgument,
@@ -11741,8 +11719,6 @@
end);
}
public void recordIllegalAccessorReturnType(ASTNode returnType, TypeBinding type) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordIllegalAccessorReturnType,
new String[] {new String(type.readableName())},
@@ -11751,8 +11727,6 @@
returnType.sourceEnd);
}
public void recordAccessorMethodShouldNotBeGeneric(ASTNode methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordAccessorMethodShouldNotBeGeneric,
NoArgument,
@@ -11761,8 +11735,6 @@
methodDecl.sourceEnd);
}
public void recordAccessorMethodShouldBePublic(ASTNode methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordAccessorMethodShouldBePublic,
NoArgument,
@@ -11771,8 +11743,6 @@
methodDecl.sourceEnd);
}
public void recordCanonicalConstructorShouldNotBeGeneric(AbstractMethodDeclaration methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCanonicalConstructorShouldNotBeGeneric,
new String[] { new String(methodDecl.selector)},
@@ -11781,8 +11751,6 @@
methodDecl.sourceEnd);
}
public void recordCanonicalConstructorHasThrowsClause(AbstractMethodDeclaration methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCanonicalConstructorHasThrowsClause,
new String[] { new String(methodDecl.selector)},
@@ -11791,8 +11759,6 @@
methodDecl.sourceEnd);
}
public void recordCanonicalConstructorHasReturnStatement(ASTNode methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCanonicalConstructorHasReturnStatement,
NoArgument,
@@ -11801,8 +11767,6 @@
methodDecl.sourceEnd);
}
public void recordCanonicalConstructorHasExplicitConstructorCall(ASTNode methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCanonicalConstructorHasExplicitConstructorCall,
NoArgument,
@@ -11811,8 +11775,6 @@
methodDecl.sourceEnd);
}
public void recordCompactConstructorHasExplicitConstructorCall(ASTNode methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordCompactConstructorHasExplicitConstructorCall,
NoArgument,
@@ -11821,8 +11783,6 @@
methodDecl.sourceEnd);
}
public void recordNestedRecordInherentlyStatic(SourceTypeBinding type) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordNestedRecordInherentlyStatic,
NoArgument,
@@ -11831,8 +11791,6 @@
type.sourceEnd());
}
public void recordAccessorMethodShouldNotBeStatic(ASTNode methodDecl) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordAccessorMethodShouldNotBeStatic,
NoArgument,
@@ -11841,8 +11799,6 @@
methodDecl.sourceEnd);
}
public void recordCannotExtendRecord(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());
@@ -11855,8 +11811,6 @@
superclass.sourceEnd);
}
public void recordComponentCannotBeVoid(RecordComponent arg) {
- if (!this.options.enablePreviewFeatures)
- return;
String[] arguments = new String[] { new String(arg.name) };
this.handle(
IProblem.RecordComponentCannotBeVoid,
@@ -11884,8 +11838,6 @@
node.sourceEnd);
}
public void recordComponentsCannotHaveModifiers(RecordComponent comp) {
- if (!this.options.enablePreviewFeatures)
- return;
String[] arguments = new String[] { new String(comp.name) };
this.handle(
IProblem.RecordComponentsCannotHaveModifiers,
@@ -11895,8 +11847,6 @@
comp.sourceEnd);
}
public void recordIllegalParameterNameInCanonicalConstructor(RecordComponentBinding comp, Argument arg) {
- if (!this.options.enablePreviewFeatures)
- return;
this.handle(
IProblem.RecordIllegalParameterNameInCanonicalConstructor,
new String[] {new String(arg.name), new String(comp.name)},
@@ -11905,8 +11855,6 @@
arg.sourceEnd);
}
public void recordIllegalExplicitFinalFieldAssignInCompactConstructor(FieldBinding field, FieldReference fieldRef) {
- if (!this.options.enablePreviewFeatures)
- return;
String[] arguments = new String[] { new String(field.name) };
this.handle(
IProblem.RecordIllegalExplicitFinalFieldAssignInCompactConstructor,