Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/pom.xml36
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java47
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java24
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java1
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java74
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java8
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java5
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_15.java105
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_15.java110
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java55
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java9
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java5
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForRecord.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_15.java356
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java930
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching15Test.java (renamed from org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java)649
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java4267
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java5308
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java26
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java299
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode13Test.java58
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java11
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java4
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java58
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java8
-rw-r--r--org.eclipse.jdt.core.tests.compiler/test.xml1
30 files changed, 12045 insertions, 436 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index 6fcc4ffd02..fa6a80b791 100644
--- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler;singleton:=true
-Bundle-Version: 3.12.1300.qualifier
+Bundle-Version: 3.12.1350.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.compiler,
diff --git a/org.eclipse.jdt.core.tests.compiler/pom.xml b/org.eclipse.jdt.core.tests.compiler/pom.xml
index 644378fcdf..9e969116bd 100644
--- a/org.eclipse.jdt.core.tests.compiler/pom.xml
+++ b/org.eclipse.jdt.core.tests.compiler/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2012, 2016 Eclipse Foundation and others.
+ Copyright (c) 2012, 2020 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
@@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core.tests.compiler</artifactId>
- <version>3.12.1300-SNAPSHOT</version>
+ <version>3.12.1350-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
@@ -169,7 +169,7 @@
<tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,12</tycho.surefire.argLine>
</properties>
</profile>
- <profile>
+ <profile>
<id>test-on-javase-13</id>
<build>
<plugins>
@@ -229,6 +229,36 @@
<tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,13,14</tycho.surefire.argLine>
</properties>
</profile>
+ <profile>
+ <id>test-on-javase-15</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-15</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,14,15</tycho.surefire.argLine>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
index cae738d087..2eabdf01ff 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
@@ -441,8 +441,6 @@ public class AbstractSyntaxTreeTest extends AbstractCompilerTest implements IDoc
}
- public void enterRecordComponent(RecordComponentInfo recordComponentInfo) {
- }
public void enterInitializer(int declarationStart, int modifiers) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
index 593174eedc..3cb88f3408 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
@@ -246,30 +246,29 @@ public void enterConstructor(MethodInfo methodInfo) {
enterAbtractMethod(methodInfo);
}
public void enterField(FieldInfo fieldInfo) {
- this.currentType.addField(
- this.currentField =
- new SourceField(
- fieldInfo.declarationStart,
- fieldInfo.modifiers,
- fieldInfo.type,
- fieldInfo.name,
- fieldInfo.nameSourceStart,
- fieldInfo.nameSourceEnd,
- this.source));
-
-}
-public void enterRecordComponent(RecordComponentInfo compInfo) {
- this.currentType.addRecordComponent(
- this.currentRecordComp =
- new SourceField(
- compInfo.declarationStart,
- compInfo.modifiers,
- compInfo.type,
- compInfo.name,
- compInfo.nameSourceStart,
- compInfo.nameSourceEnd,
- this.source));
-
+ if (fieldInfo.isRecordComponent) {
+ this.currentType.addRecordComponent(
+ this.currentRecordComp =
+ new SourceField(
+ fieldInfo.declarationStart,
+ fieldInfo.modifiers,
+ fieldInfo.type,
+ fieldInfo.name,
+ fieldInfo.nameSourceStart,
+ fieldInfo.nameSourceEnd,
+ this.source));
+ } else {
+ this.currentType.addField(
+ this.currentField =
+ new SourceField(
+ fieldInfo.declarationStart,
+ fieldInfo.modifiers,
+ fieldInfo.type,
+ fieldInfo.name,
+ fieldInfo.nameSourceStart,
+ fieldInfo.nameSourceEnd,
+ this.source));
+ }
}
public void enterInitializer(int declarationSourceStart, int modifiers) {
this.currentType.addField(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
index d20ccdd71c..b87490630b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -252,6 +252,28 @@ public static TestSuite getTestSuite(boolean addComplianceDiagnoseTest) {
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_14), tests_14));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_15) != 0) {
+ ArrayList tests_15 = (ArrayList)testClasses.clone();
+ tests_15.addAll(TEST_CLASSES_1_5);
+ tests_15.add(ParserTest1_7.class);
+ tests_15.add(LambdaExpressionSyntaxTest.class);
+ tests_15.add(ReferenceExpressionSyntaxTest.class);
+ tests_15.add(TypeAnnotationSyntaxTest.class);
+ tests_15.add(CompletionParserTest18.class);
+ tests_15.add(SelectionParserTest18.class);
+ tests_15.add(SelectionParserTest9.class);
+ tests_15.add(SelectionParserTest10.class);
+ tests_15.add(SelectionParserTest12.class);
+ tests_15.add(ModuleDeclarationSyntaxTest.class);
+ tests_15.add(JEP286ReservedWordTest.class);
+ // Reset forgotten subsets tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS= null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_15), tests_15));
+ }
return all;
}
public static Test suite() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java
index fda10faada..6287d57867 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java
@@ -89,7 +89,6 @@ public void enterConstructor(MethodInfo methodInfo) {}
* enterField method comment.
*/
public void enterField(FieldInfo fieldInfo) {}
-public void enterRecordComponent(RecordComponentInfo recordComponentInfo) {}
/**
* enterMethod method comment.
*/
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 335bf6ab3a..5816ad808a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -307,6 +307,8 @@ static class JavacCompiler {
return JavaCore.VERSION_13;
} else if(rawVersion.startsWith("14")) {
return JavaCore.VERSION_14;
+ } else if(rawVersion.startsWith("15")) {
+ return JavaCore.VERSION_15;
} else {
throw new RuntimeException("unknown javac version: " + rawVersion);
}
@@ -462,6 +464,20 @@ static class JavacCompiler {
return 0200;
}
}
+ if (version == JavaCore.VERSION_15) {
+ if ("15-ea".equals(rawVersion)) {
+ return 0000;
+ }
+ if ("15".equals(rawVersion)) {
+ return 0000;
+ }
+ if ("15.0.1".equals(rawVersion)) {
+ return 0100;
+ }
+ if ("15.0.2".equals(rawVersion)) {
+ return 0200;
+ }
+ }
throw new RuntimeException("unknown raw javac version: " + rawVersion);
}
// returns 0L if everything went fine; else the lower word contains the
@@ -1202,7 +1218,7 @@ protected static class JavacTestOptions {
public final static String MODULE_INFO_NAME = new String(TypeConstants.MODULE_INFO_NAME);
public static boolean SHIFT = false;
- public static String PREVIEW_ALLOWED_LEVEL = JavaCore.VERSION_14;
+ public static String PREVIEW_ALLOWED_LEVEL = JavaCore.VERSION_15;
protected static final String SOURCE_DIRECTORY = Util.getOutputDirectory() + File.separator + "source";
@@ -1215,7 +1231,7 @@ protected static class JavacTestOptions {
super(name);
}
protected boolean checkPreviewAllowed() {
- return this.complianceLevel == ClassFileConstants.JDK14;
+ return this.complianceLevel == ClassFileConstants.JDK15;
}
protected void checkClassFile(String className, String source, String expectedOutput) throws ClassFormatException, IOException {
this.checkClassFile("", className, source, expectedOutput, ClassFileBytesDisassembler.SYSTEM);
@@ -1396,6 +1412,8 @@ protected static class JavacTestOptions {
int major = (int)(this.complianceLevel>>16);
buffer.append("\" -" + (major - ClassFileConstants.MAJOR_VERSION_0));
}
+ if (this.complianceLevel == ClassFileConstants.getLatestJDKLevel() && this.enablePreview)
+ buffer.append(" --enable-preview ");
buffer
.append(" -preserveAllLocals -proceedOnError -nowarn -g -classpath \"")
.append(Util.getJavaClassLibsAsString())
@@ -3770,6 +3788,52 @@ protected void runNegativeTest(
// javac options
javacTestOptions /* javac test options */);
}
+//runNegativeTest(
+//// test directory preparation
+//new String[] { /* test files */
+//},
+//null /* no test files */,
+//// compiler results
+//"----------\n" + /* expected compiler log */
+//// javac options
+//JavacTestOptions.SKIP /* skip javac tests */);
+//JavacTestOptions.DEFAULT /* default javac test options */);
+//javacTestOptions /* javac test options */);
+protected void runNegativeTest(
+// test directory preparation
+String[] testFiles,
+String[] dependentFiles,
+// compiler results
+String expectedCompilerLog,
+// javac options
+JavacTestOptions javacTestOptions) {
+ runTest(
+ // test directory preparation
+ true /* flush output directory */,
+ testFiles /* test files */,
+ dependentFiles,
+ // compiler options
+ null /* no class libraries */,
+ false,
+ null /* no custom options */,
+ false /* do not perform statements recovery */,
+ null /* no custom requestor */,
+ // compiler results
+ true /* expecting compiler errors */,
+ expectedCompilerLog /* expected compiler log */,
+ // runtime options
+ null,
+ false /* do not force execution */,
+ null /* no vm arguments */,
+ // runtime results
+ null /* do not check output string */,
+ null /* do not check error string */,
+ null,
+ null,
+ // javac options
+ javacTestOptions /* javac test options */,
+ Charset.defaultCharset());
+}
// runNegativeTest(
// // test directory preparation
// true /* flush output directory */,
@@ -4017,9 +4081,9 @@ protected void runNegativeTest(
}
protected Map<String, String> setPresetPreviewOptions() {
Map<String, String> options = getCompilerOptions();
- options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_14);
- options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_14);
- options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_14);
+ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_15);
+ options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_15);
+ options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_15);
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
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/AutoBoxingTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
index 909cc99731..bbb2bce8e7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -3776,6 +3776,10 @@ public void test123() {
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=155255 - variation
public void test124() {
+ String specVersion = System.getProperty("java.specification.version");
+ isJRE15Plus = Integer.valueOf(specVersion) >= Integer.valueOf(CompilerOptions.VERSION_15);
+ String bounds = isJRE15Plus ? "Object&Serializable&Comparable<?>&Constable" : "Object&Serializable&Comparable<?>";
+
this.runNegativeTest(
new String[] {
"X.java",
@@ -3802,7 +3806,7 @@ public void test124() {
"1. ERROR in X.java (at line 3)\n" +
" boolean x = false ? \"\" : false;\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from Object&Serializable&Comparable<?> to boolean\n" +
+ "Type mismatch: cannot convert from "+ bounds +" to boolean\n" +
"----------\n" +
"2. WARNING in X.java (at line 3)\n" +
" boolean x = false ? \"\" : false;\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index bd2e14871e..18c65befb9 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -674,9 +674,10 @@ public void test012(){
" -12 -12.0 use 12 compliance (-source 12 -target 12)\n" +
" -13 -13.0 use 13 compliance (-source 13 -target 13)\n" +
" -14 -14.0 use 14 compliance (-source 14 -target 14)\n" +
- " -source <version> set source level: 1.3 to 1.9, 10 to 14\n" +
+ " -15 -15.0 use 15 compliance (-source 15 -target 15)\n" +
+ " -source <version> set source level: 1.3 to 1.9, 10 to 15\n" +
" (or 6, 6.0, etc)\n" +
- " -target <version> set classfile target: 1.3 to 1.9, 10 to 14\n" +
+ " -target <version> set classfile target: 1.3 to 1.9, 10 to 15\n" +
" (or 6, 6.0, etc)\n" +
" cldc1.1 can also be used to generate the StackMap\n" +
" attribute\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_15.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_15.java
new file mode 100644
index 0000000000..de0b950662
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_15.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2018, 2020 IBM Corporation.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.tests.util.Util;
+import junit.framework.Test;
+
+@SuppressWarnings({ "rawtypes" })
+public class BatchCompilerTest_15 extends AbstractBatchCompilerTest {
+
+ static {
+// TESTS_NAMES = new String[] { "test440477" };
+// TESTS_NUMBERS = new int[] { 306 };
+// TESTS_RANGE = new int[] { 298, -1 };
+ }
+
+ /**
+ * This test suite only needs to be run on one compliance.
+ * As it includes some specific 1.5 tests, it must be used with a least a 1.5 VM
+ * and not be duplicated in general test suite.
+ * @see TestAll
+ */
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
+ }
+ public static Class testClass() {
+ return BatchCompilerTest_15.class;
+ }
+ public BatchCompilerTest_15(String name) {
+ super(name);
+ }
+ public void testBug564047_001(){
+ String currentWorkingDirectoryPath = System.getProperty("user.dir");
+ if (currentWorkingDirectoryPath == null) {
+ System.err.println("BatchCompilerTest#testBug564047_001 could not access the current working directory " + currentWorkingDirectoryPath);
+ } else if (!new File(currentWorkingDirectoryPath).isDirectory()) {
+ System.err.println("BatchCompilerTest#testBug564047_001 current working directory is not a directory " + currentWorkingDirectoryPath);
+ } else {
+ String lib1Path = currentWorkingDirectoryPath + File.separator + "lib1.jar";
+ try {
+ Util.createJar(
+ new String[] {
+ "p/Y.java",
+ "package p;\n" +
+ "public sealed class Y permits Z{}",
+ "p/Z.java",
+ "package p;\n" +
+ "public final class Z extends Y{}",
+ },
+ lib1Path,
+ JavaCore.VERSION_15,
+ true);
+ this.runNegativeTest(
+ new String[] {
+ "src/p/X.java",
+ "package p;\n" +
+ "public class X extends Y {\n" +
+ " public static void main(String[] args){\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "src/p/X.java\""
+ + " -cp " + lib1Path // relative
+ + " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\""
+ + " --release 15 --enable-preview -g -preserveAllLocals"
+ + " -proceedOnError -referenceInfo"
+ + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
+ "",
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 2)\n" +
+ " public class X extends Y {\n" +
+ " ^\n" +
+ "The class X with a sealed direct superclass or a sealed direct superinterface Y should be declared either final, sealed, or non-sealed\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 2)\n" +
+ " public class X extends Y {\n" +
+ " ^\n" +
+ "The type X extending a sealed class Y should be a permitted subtype of Y\n" +
+ "----------\n" +
+ "2 problems (2 errors)\n",
+ true);
+ } catch (IOException e) {
+ System.err.println("BatchCompilerTest#testBug563430_001 could not write to current working directory " + currentWorkingDirectoryPath);
+ } finally {
+ new File(lib1Path).delete();
+ }
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_15.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_15.java
new file mode 100644
index 0000000000..0b104733e0
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_15.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2020 GoPivotal, Inc and others
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
+ * Bug 407191 - [1.8] Binary access support for type annotations
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
+
+@SuppressWarnings({ "rawtypes" })
+public class ClassFileReaderTest_15 extends AbstractRegressionTest {
+ static {
+ }
+
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
+ }
+ public static Class testClass() {
+ return ClassFileReaderTest_15.class;
+ }
+
+ public ClassFileReaderTest_15(String name) {
+ super(name);
+ }
+
+ // Needed to run tests individually from JUnit
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.complianceLevel = ClassFileConstants.JDK15;
+ this.enablePreview = true;
+ }
+
+ public void testBug564227_001() throws Exception {
+ String source =
+ "sealed class X permits Y, Z{\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "final class Y extends X{}\n" +
+ "final class Z extends X{}\n";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+ char[][] permittedSubtypesNames = classFileReader.getPermittedSubtypeNames();
+
+ assertEquals(2, permittedSubtypesNames.length);
+
+ char [][] expected = {"Y".toCharArray(), "Z".toCharArray()};
+ assertTrue(CharOperation.equals(permittedSubtypesNames, expected));
+
+ }
+ public void testBug565782_001() throws Exception {
+ String source =
+ "sealed interface I {}\n"+
+ "enum X implements I {\n"+
+ " ONE {};\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+ char[][] permittedSubtypesNames = classFileReader.getPermittedSubtypeNames();
+
+ assertEquals(1, permittedSubtypesNames.length);
+
+ char [][] expected = {"X$1".toCharArray()};
+ assertTrue(CharOperation.equals(permittedSubtypesNames, expected));
+
+ int modifiers = classFileReader.getModifiers();
+ assertTrue("sealed modifier expected", (modifiers & ExtraCompilerModifiers.AccSealed) != 0);
+ }
+ public void testBug565782_002() throws Exception {
+ String source =
+ "sealed interface I {}\n"+
+ "class X {\n"+
+ " enum E implements I {\n"+
+ " ONE {};\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X.E", "X$E", source);
+ char[][] permittedSubtypesNames = classFileReader.getPermittedSubtypeNames();
+
+ assertEquals(1, permittedSubtypesNames.length);
+
+ char [][] expected = {"X$E$1".toCharArray()};
+ assertTrue(CharOperation.equals(permittedSubtypesNames, expected));
+
+ int modifiers = classFileReader.getModifiers();
+ assertTrue("sealed modifier expected", (modifiers & ExtraCompilerModifiers.AccSealed) != 0);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 3bffaba5df..4d631ef860 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -721,6 +721,7 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("JavadocInheritedNameHidesEnclosingTypeName", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocInternalTypeNameProvided", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidMemberTypeQualification", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
+ expectedProblemAttributes.put("JavadocInvalidModuleQualification", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidParamName", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidParamTagName", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidParamTagTypeParameter", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
@@ -1201,6 +1202,7 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("PreviewFeatureUsed", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("PreviewFeatureNotSupported", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("PreviewFeaturesNotAllowed", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("FeatureNotSupported", new ProblemAttributes(CategorizedProblem.CAT_COMPLIANCE));
expectedProblemAttributes.put("SwitchExpressionsYieldIncompatibleResultExpressionTypes", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("SwitchExpressionsYieldEmptySwitchBlock", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("SwitchExpressionsYieldNoResultExpression", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -1232,13 +1234,13 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("RecordNonStaticFieldDeclarationInRecord", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordAccessorMethodHasThrowsClause", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordCanonicalConstructorHasThrowsClause", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
- expectedProblemAttributes.put("RecordCanonicalConstructorShouldBePublic", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("RecordCanonicalConstructorVisibilityReduced", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordMultipleCanonicalConstructors", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordCompactConstructorHasReturnStatement", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordDuplicateComponent", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordIllegalNativeModifierInRecord", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordInstanceInitializerBlockInRecord", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
- expectedProblemAttributes.put("RecordIsAReservedTypeName", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("RestrictedTypeName", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordIllegalAccessorReturnType", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordAccessorMethodShouldNotBeGeneric", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordAccessorMethodShouldBePublic", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
@@ -1253,7 +1255,28 @@ public void test011_problem_categories() {
expectedProblemAttributes.put("RecordIllegalVararg", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordStaticReferenceToOuterLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordCannotDefineRecordInLocalType", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("RecordComponentsCannotHaveModifiers", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("RecordIllegalParameterNameInCanonicalConstructor", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("RecordIllegalExplicitFinalFieldAssignInCompactConstructor", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
expectedProblemAttributes.put("RecordMissingExplicitConstructorCallInNonCanonicalConstructor", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("RecordIllegalStaticModifierForLocalClassOrInterface", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("LocalStaticsIllegalVisibilityModifierForInterfaceLocalType", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedMissingClassModifier", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedDisAllowedNonSealedModifierInClass", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedSuperClassDoesNotPermit", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedSuperInterfaceDoesNotPermit", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedMissingSealedModifier", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedMissingInterfaceModifier", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedDuplicateTypeInPermits", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedNotDirectSuperClass", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedPermittedTypeOutsideOfModule", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedPermittedTypeOutsideOfPackage", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedSealedTypeMissingPermits", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedInterfaceIsSealedAndNonSealed", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedDisAllowedNonSealedModifierInInterface", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedNotDirectSuperInterface", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedLocalDirectSuperTypeSealed", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
+ expectedProblemAttributes.put("SealedAnonymousClassCannotExtendSealedType", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED));
StringBuffer failures = new StringBuffer();
StringBuffer correctResult = new StringBuffer(70000);
Field[] fields = (iProblemClass = IProblem.class).getFields();
@@ -1745,6 +1768,7 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("JavadocInheritedNameHidesEnclosingTypeName", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocInternalTypeNameProvided", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidMemberTypeQualification", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
+ expectedProblemAttributes.put("JavadocInvalidModuleQualification", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidParamName", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidParamTagName", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocInvalidParamTagTypeParameter", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
@@ -2227,6 +2251,7 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("PreviewFeatureUsed", SKIP);
expectedProblemAttributes.put("PreviewFeatureNotSupported", SKIP);
expectedProblemAttributes.put("PreviewFeaturesNotAllowed", SKIP);
+ expectedProblemAttributes.put("FeatureNotSupported", SKIP);
expectedProblemAttributes.put("SwitchExpressionsYieldIncompatibleResultExpressionTypes", SKIP);
expectedProblemAttributes.put("SwitchExpressionsYieldEmptySwitchBlock", SKIP);
expectedProblemAttributes.put("SwitchExpressionsYieldNoResultExpression", SKIP);
@@ -2258,13 +2283,13 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("RecordNonStaticFieldDeclarationInRecord", SKIP);
expectedProblemAttributes.put("RecordAccessorMethodHasThrowsClause", SKIP);
expectedProblemAttributes.put("RecordCanonicalConstructorHasThrowsClause", SKIP);
- expectedProblemAttributes.put("RecordCanonicalConstructorShouldBePublic", SKIP);
+ expectedProblemAttributes.put("RecordCanonicalConstructorVisibilityReduced", SKIP);
expectedProblemAttributes.put("RecordMultipleCanonicalConstructors", SKIP);
expectedProblemAttributes.put("RecordCompactConstructorHasReturnStatement", SKIP);
expectedProblemAttributes.put("RecordDuplicateComponent", SKIP);
expectedProblemAttributes.put("RecordIllegalNativeModifierInRecord", SKIP);
expectedProblemAttributes.put("RecordInstanceInitializerBlockInRecord", SKIP);
- expectedProblemAttributes.put("RecordIsAReservedTypeName", SKIP);
+ expectedProblemAttributes.put("RestrictedTypeName", SKIP);
expectedProblemAttributes.put("RecordIllegalAccessorReturnType", SKIP);
expectedProblemAttributes.put("RecordAccessorMethodShouldNotBeGeneric", SKIP);
expectedProblemAttributes.put("RecordAccessorMethodShouldBePublic", SKIP);
@@ -2280,6 +2305,28 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("RecordStaticReferenceToOuterLocalVariable",SKIP);
expectedProblemAttributes.put("RecordCannotDefineRecordInLocalType",SKIP);
expectedProblemAttributes.put("RecordMissingExplicitConstructorCallInNonCanonicalConstructor",SKIP);
+ expectedProblemAttributes.put("RecordIllegalStaticModifierForLocalClassOrInterface", SKIP);
+ expectedProblemAttributes.put("RecordComponentsCannotHaveModifiers",SKIP);
+ expectedProblemAttributes.put("RecordIllegalParameterNameInCanonicalConstructor",SKIP);
+ expectedProblemAttributes.put("RecordIllegalExplicitFinalFieldAssignInCompactConstructor",SKIP);
+ expectedProblemAttributes.put("LocalStaticsIllegalVisibilityModifierForInterfaceLocalType",SKIP);
+ expectedProblemAttributes.put("SealedMissingClassModifier", SKIP);
+ expectedProblemAttributes.put("SealedDisAllowedNonSealedModifierInClass", SKIP);
+ expectedProblemAttributes.put("SealedSuperClassDoesNotPermit", SKIP);
+ expectedProblemAttributes.put("SealedSuperInterfaceDoesNotPermit", SKIP);
+ expectedProblemAttributes.put("SealedMissingSealedModifier", SKIP);
+ expectedProblemAttributes.put("SealedMissingInterfaceModifier", SKIP);
+ expectedProblemAttributes.put("SealedDuplicateTypeInPermits", SKIP);
+ expectedProblemAttributes.put("SealedNotDirectSuperClass", SKIP);
+ expectedProblemAttributes.put("SealedPermittedTypeOutsideOfModule", SKIP);
+ expectedProblemAttributes.put("SealedPermittedTypeOutsideOfPackage", SKIP);
+ expectedProblemAttributes.put("SealedSealedTypeMissingPermits", SKIP);
+ expectedProblemAttributes.put("SealedInterfaceIsSealedAndNonSealed", SKIP);
+ expectedProblemAttributes.put("SealedDisAllowedNonSealedModifierInInterface", SKIP);
+ expectedProblemAttributes.put("SealedSuperInterfaceDoesNotPermit", SKIP);
+ expectedProblemAttributes.put("SealedNotDirectSuperInterface", SKIP);
+ expectedProblemAttributes.put("SealedLocalDirectSuperTypeSealed", SKIP);
+ expectedProblemAttributes.put("SealedAnonymousClassCannotExtendSealedType", SKIP);
Map constantNamesIndex = new HashMap();
Field[] fields = JavaCore.class.getFields();
for (int i = 0, length = fields.length; i < length; i++) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 47beae1a92..d1ddc6b84a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -56,7 +56,7 @@ public class GenericTypeTest extends AbstractComparableTest {
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test1277" };
+// TESTS_NAMES = new String[] { "test0593" };
// TESTS_NUMBERS = new int[] { 470, 627 };
// TESTS_RANGE = new int[] { 1097, -1 };
}
@@ -5401,7 +5401,7 @@ public class GenericTypeTest extends AbstractComparableTest {
customOptions);
}
public void test0178a() {
- if (this.complianceLevel < ClassFileConstants.JDK14)
+ if (this.complianceLevel < ClassFileConstants.JDK15)
return;
Map customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
@@ -5421,7 +5421,7 @@ public class GenericTypeTest extends AbstractComparableTest {
" return t;\n" +
" } else if (t instanceof T) {\n" +
" return t;\n" +
- " } else if (t instanceof X) { // this is allowed since Java 14 as preview feature\n" +
+ " } else if (t instanceof X) { // this is allowed since Java 15 as preview feature\n" +
" return t;\n" +
" }\n" +
" return null;\n" +
@@ -18808,6 +18808,7 @@ X.java:6: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasur
public void test0593() {
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
+ String bounds = isJRE15Plus ? "Object&Serializable&Comparable<?>&Constable" : "Object&Serializable&Comparable<?>";
String xSource =
"import java.util.*;\n" +
"public class X {\n" +
@@ -18824,7 +18825,7 @@ X.java:6: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasur
"1. ERROR in X.java (at line 3)\n" +
" List<Class<?>> classes1 = Arrays.asList(String.class, Boolean.class);\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type mismatch: cannot convert from List<Class<? extends Object&Serializable&Comparable<?>>> to List<Class<?>>\n" +
+ "Type mismatch: cannot convert from List<Class<? extends " + bounds + ">> to List<Class<?>>\n" +
"----------\n",
null,
true,
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java
index 66e672d6cb..6c933b4793 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java
@@ -5,7 +5,7 @@
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
- *
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -89,6 +89,9 @@ public abstract class JavadocTest extends AbstractRegressionTest {
if ((complianceLevels & AbstractCompilerTest.F_14) != 0) {
testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTestForRecord.class, ClassFileConstants.JDK14));
}
+ if ((complianceLevels & AbstractCompilerTest.F_15) != 0) {
+ testSuite.addTest(buildUniqueComplianceTestSuite(JavadocTest_15.class, ClassFileConstants.JDK15));
+ }
return testSuite;
}
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 4d56617859..8d8597d491 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
@@ -56,7 +56,7 @@ public class JavadocTestForRecord extends JavadocTest {
}
public static Test suite() {
- return buildMinimalComplianceTestSuite(testClass(), F_14);
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -94,9 +94,9 @@ public class JavadocTestForRecord extends JavadocTest {
options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
options.put(CompilerOptions.OPTION_ReportMissingJavadocTagsMethodTypeParameters, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_Release, CompilerOptions.ENABLED);
- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14); // FIXME
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15); // FIXME
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
return options;
@@ -109,7 +109,7 @@ public class JavadocTestForRecord extends JavadocTest {
@Override
protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
- runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("14"));
+ runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("15"));
}
@Override
@@ -125,7 +125,7 @@ public class JavadocTestForRecord extends JavadocTest {
runner.expectedOutputString = expectedOutput;
runner.vmArguments = new String[] { "--enable-preview" };
runner.customOptions = customOptions;
- runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("14");
+ runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("15");
runner.runConformTest();
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_15.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_15.java
new file mode 100644
index 0000000000..b3d9f6d4c0
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_15.java
@@ -0,0 +1,356 @@
+/*******************************************************************************
+ * Copyright (c) 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class JavadocTest_15 extends JavadocTest {
+
+ String docCommentSupport = CompilerOptions.ENABLED;
+ String reportInvalidJavadoc = CompilerOptions.ERROR;
+ String reportMissingJavadocDescription = CompilerOptions.RETURN_TAG;
+ String reportInvalidJavadocVisibility = CompilerOptions.PRIVATE;
+ String reportMissingJavadocTags = CompilerOptions.ERROR;
+ String reportMissingJavadocComments = null;
+ String reportMissingJavadocCommentsVisibility = null;
+ String reportDeprecation = CompilerOptions.ERROR;
+ String reportJavadocDeprecation = null;
+ String processAnnotations = null;
+
+public JavadocTest_15(String name) {
+ super(name);
+}
+
+public static Class javadocTestClass() {
+ return JavadocTest_15.class;
+}
+
+// Use this static initializer to specify subset for tests
+// All specified tests which does not belong to the class are skipped...
+static {
+
+}
+
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(javadocTestClass(), F_15);
+}
+
+@Override
+protected Map getCompilerOptions() {
+ Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_DocCommentSupport, this.docCommentSupport);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, this.reportInvalidJavadoc);
+ if (!CompilerOptions.IGNORE.equals(this.reportInvalidJavadoc)) {
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, this.reportInvalidJavadocVisibility);
+ }
+ if (this.reportJavadocDeprecation != null) {
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsDeprecatedRef, this.reportJavadocDeprecation);
+ }
+ if (this.reportMissingJavadocComments != null) {
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocComments, this.reportMissingJavadocComments);
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocCommentsOverriding, CompilerOptions.ENABLED);
+ if (this.reportMissingJavadocCommentsVisibility != null) {
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocCommentsVisibility, this.reportMissingJavadocCommentsVisibility);
+ }
+ } else {
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocComments, this.reportInvalidJavadoc);
+ }
+ if (this.reportMissingJavadocTags != null) {
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocTags, this.reportMissingJavadocTags);
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocTagsOverriding, CompilerOptions.ENABLED);
+ } else {
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocTags, this.reportInvalidJavadoc);
+ }
+ if (this.reportMissingJavadocDescription != null) {
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocTagDescription, this.reportMissingJavadocDescription);
+ }
+ if (this.processAnnotations != null) {
+ options.put(CompilerOptions.OPTION_Process_Annotations, this.processAnnotations);
+ }
+ options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportDeprecation, this.reportDeprecation);
+ options.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
+ return options;
+}
+/* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+@Override
+protected void setUp() throws Exception {
+ super.setUp();
+ this.docCommentSupport = CompilerOptions.ENABLED;
+ this.reportInvalidJavadoc = CompilerOptions.ERROR;
+ this.reportInvalidJavadocVisibility = CompilerOptions.PRIVATE;
+ this.reportMissingJavadocTags = CompilerOptions.IGNORE;
+ this.reportMissingJavadocComments = CompilerOptions.IGNORE;
+ this.reportMissingJavadocCommentsVisibility = CompilerOptions.PUBLIC;
+ this.reportDeprecation = CompilerOptions.ERROR;
+}
+
+public void test001() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+
+ String moduleInfo = "" +
+ "/**\n" +
+ " */\n" +
+ "module mod.one { \n" +
+ " exports p;\n" +
+ "}";
+ String I1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * interface I1\n" +
+ " * @see mod.one/\n" +
+ " */\n" +
+ "interface I1 {\n" +
+ " /**\n" +
+ " * Method foo\n" +
+ " * @return int\n" +
+ " */\n" +
+ " public int foo();\n" +
+ "}";
+
+ String P1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * class P1\n" +
+ " * @see mod.one/p.I1\n" +
+ " */\n" +
+ "public class P1 implements I1 {\n" +
+ " @Override\n" +
+ " public int foo() { return 0; }\n" +
+ "}";
+
+ this.runConformTest(new String[] {"p/I1.java", I1 ,"p/P1.java" , P1 } ,
+ new String[] {"module-info.java", moduleInfo }, "" );
+}
+
+public void test002() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+
+ String moduleInfo = "" +
+ "/**\n" +
+ " */\n" +
+ "module mod.one { \n" +
+ " exports p;\n" +
+ "}";
+ String I1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * interface I1\n" +
+ " * {@link mod.one/}\n" +
+ " */\n" +
+ "interface I1 {\n" +
+ " /**\n" +
+ " * Method foo\n" +
+ " * @return int\n" +
+ " */\n" +
+ " public int foo();\n" +
+ "}";
+
+ String P1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * class P1\n" +
+ " * {@link mod.one/p.I1}\n" +
+ " */\n" +
+ "public class P1 implements I1 {\n" +
+ " @Override\n" +
+ " public int foo() { return 0; }\n" +
+ "}";
+
+ this.runConformTest(new String[] {"p/I1.java", I1 ,"p/P1.java" , P1 } ,
+ new String[] {"module-info.java", moduleInfo }, "" );
+}
+
+public void test003() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+
+ String moduleInfo = "" +
+ "/**\n" +
+ " */\n" +
+ "module mod.one { \n" +
+ " exports p;\n" +
+ "}";
+ String I1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * interface I1\n" +
+ " * {@linkplain mod.one/}\n" +
+ " */\n" +
+ "interface I1 {\n" +
+ " /**\n" +
+ " * Method foo\n" +
+ " * @return int\n" +
+ " */\n" +
+ " public int foo();\n" +
+ "}";
+
+ String P1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * class P1\n" +
+ " * {@linkplain mod.one/p.I1}\n" +
+ " */\n" +
+ "public class P1 implements I1 {\n" +
+ " @Override\n" +
+ " public int foo() { return 0; }\n" +
+ "}";
+
+ this.runConformTest(new String[] {"p/I1.java", I1 ,"p/P1.java" , P1 } ,
+ new String[] {"module-info.java", moduleInfo }, "" );
+}
+
+public void test004() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+
+ String moduleInfo = "" +
+ "/**\n" +
+ " */\n" +
+ "module mod.one { \n" +
+ " exports p;\n" +
+ "}";
+ String I1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * interface I1\n" +
+ " * {@linkplain mod.one/}\n" +
+ " */\n" +
+ "interface I1 {\n" +
+ " /**\n" +
+ " * Method foo\n" +
+ " * @return int\n" +
+ " */\n" +
+ " public int foo();\n" +
+ "}";
+
+ String P1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * class P1\n" +
+ " * {@linkplain mod.one/p.P1#foo()}\n" +
+ " */\n" +
+ "public class P1 implements I1 {\n" +
+ " @Override\n" +
+ " public int foo() { return 0; }\n" +
+ "}";
+
+ this.runConformTest(new String[] {"p/I1.java", I1 ,"p/P1.java" , P1 } ,
+ new String[] {"module-info.java", moduleInfo }, "" );
+}
+
+public void test005() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+
+ String moduleInfo = "" +
+ "/**\n" +
+ " */\n" +
+ "module mod.one { \n" +
+ " exports p;\n" +
+ "}";
+ String I1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * interface I1\n" +
+ " * {@linkplain mod.one/}\n" +
+ " */\n" +
+ "interface I1 {\n" +
+ " /**\n" +
+ " * Method foo\n" +
+ " * @return int\n" +
+ " */\n" +
+ " public int foo();\n" +
+ "}";
+
+ String P1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * class P1\n" +
+ " * {@linkplain mod.one/p.P1#abc}\n" +
+ " */\n" +
+ "public class P1 implements I1 {\n" +
+ " public int abc;\n" +
+ " @Override\n" +
+ " public int foo() { return 0; }\n" +
+ "}";
+
+ this.runConformTest(new String[] {"p/I1.java", I1 ,"p/P1.java" , P1 } ,
+ new String[] {"module-info.java", moduleInfo }, "" );
+}
+
+public void test006() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+
+ String moduleInfo = "" +
+ "/**\n" +
+ " */\n" +
+ "module mod.one { \n" +
+ " exports p;\n" +
+ "}";
+ String I1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * interface I1\n" +
+ " * {@linkplain mod.one/}\n" +
+ " */\n" +
+ "interface I1 {\n" +
+ " /**\n" +
+ " * Method foo\n" +
+ " * @return int\n" +
+ " */\n" +
+ " public int foo();\n" +
+ "}";
+
+ String P1 = "" +
+ "package p;\n" +
+ "/**\n" +
+ " * class P1\n" +
+ " * {@linkplain mod.one/p.P1#abd}\n" +
+ " */\n" +
+ "public class P1 implements I1 {\n" +
+ " public int abc;\n" +
+ " @Override\n" +
+ " public int foo() { return 0; }\n" +
+ "}";
+ String errorMsg = "" +
+ "----------\n" +
+ "1. ERROR in p\\P1.java (at line 4)\n" +
+ " * {@linkplain mod.one/p.P1#abd}\n" +
+ " ^^^\n" +
+ "Javadoc: abd cannot be resolved or is not a field\n" +
+ "----------\n";
+
+ this.runNegativeTest(new String[] {"p/I1.java", I1 ,"p/P1.java" , P1 } ,
+ new String[] {"module-info.java", moduleInfo }, errorMsg,
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+}
+
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
index 1f430b4616..7a94b5ec82 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaExpressionsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2018 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -39,7 +39,7 @@ import junit.framework.Test;
public class LambdaExpressionsTest extends AbstractRegressionTest {
static {
-// TESTS_NAMES = new String[] { "testBug540520"};
+// TESTS_NAMES = new String[] { "test056"};
// TESTS_NUMBERS = new int[] { 50 };
// TESTS_RANGE = new int[] { 11, -1 };
}
@@ -1605,6 +1605,7 @@ public void test055() {
"");
}
public void test056() {
+ String expected = isJRE15Plus ? "Cannot invoke \"Object.getClass()\" because \"x\" is null" : "null";
this.runConformTest(
new String[] {
"X.java",
@@ -1626,7 +1627,7 @@ public void test056() {
" }\n" +
"}\n"
},
- "null");
+ expected);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=410114, [1.8] CCE when trying to parse method reference expression with inappropriate type arguments
public void test057() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
new file mode 100644
index 0000000000..848fb0ecfe
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
@@ -0,0 +1,930 @@
+/*******************************************************************************
+ * Copyright (c) 2020 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
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
+import org.eclipse.jdt.core.util.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+public class LocalStaticsTest_15 extends AbstractRegressionTest {
+
+ static {
+// TESTS_NUMBERS = new int [] { 40 };
+// TESTS_RANGE = new int[] { 1, -1 };
+// TESTS_NAMES = new String[] { "testBug566715_003"};
+ }
+
+ public static Class<?> testClass() {
+ return LocalStaticsTest_15.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
+ }
+ public LocalStaticsTest_15(String testName){
+ super(testName);
+ }
+
+ // Enables the tests to run individually
+ protected Map<String, String> getCompilerOptions() {
+ Map<String, String> defaultOptions = super.getCompilerOptions();
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15); // FIXME
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ defaultOptions.put(CompilerOptions.OPTION_Store_Annotations, CompilerOptions.ENABLED);
+ return defaultOptions;
+ }
+
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput) {
+ runConformTest(testFiles, expectedOutput, getCompilerOptions());
+ }
+
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
+ Runner runner = new Runner();
+ runner.testFiles = testFiles;
+ runner.expectedOutputString = expectedOutput;
+ runner.vmArguments = new String[] {"--enable-preview"};
+ runner.customOptions = customOptions;
+ runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("15");
+ runner.runConformTest();
+ }
+ @Override
+ protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
+ runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("15"));
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog) {
+ runWarningTest(testFiles, expectedCompilerLog, null);
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog, Map<String, String> customOptions) {
+ runWarningTest(testFiles, expectedCompilerLog, customOptions, null);
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog,
+ Map<String, String> customOptions, String javacAdditionalTestOptions) {
+
+ 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.runWarningTest();
+ }
+
+ @SuppressWarnings("unused")
+ private static void verifyClassFile(String expectedOutput, String classFileName, int mode)
+ throws IOException, ClassFormatException {
+ File f = new File(OUTPUT_DIR + File.separator + classFileName);
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", mode);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ System.out.println("...");
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ }
+
+ public void testBug566284_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " interface F {\n"+
+ " static int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(F.create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+
+ public void testBug566284_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " record R() {\n"+
+ " static int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(R.create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+ public void testBug566284_003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " static int si;\n"+
+ " int nsi;\n"+
+ "\n"+
+ " void m() {\n"+
+ " int li;\n"+
+ "\n"+
+ " interface F {\n"+
+ " static int fi = 0;\n"+
+ "\n"+
+ " default void foo(int i) {\n"+
+ " System.out.println(li); // error, local variable of method of outer enclosing class\n"+
+ " System.out.println(nsi); // error, non-static member\n"+
+ " System.out.println(fi); // ok, static member of current class\n"+
+ " System.out.println(si); // ok, static member of enclosing class\n"+
+ " System.out.println(i); // ok, local variable of current method\n"+
+ " }\n"+
+ "\n"+
+ " static void bar(int lo) {\n"+
+ " int k = lo; // ok\n"+
+ " int j = fi; // ok\n"+
+ " I myI = s -> lo; // ok, local var of method\n"+
+ " }\n"+
+ "\n"+
+ " static void bar2(int lo) {\n"+
+ " I myI = s -> li; // error - local var of outer class\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " System.out.println(li); // error, local variable of method of outer enclosing class\n" +
+ " ^^\n" +
+ "Cannot make a static reference to the non-static variable li\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 13)\n" +
+ " System.out.println(nsi); // error, non-static member\n" +
+ " ^^^\n" +
+ "Cannot make a static reference to the non-static field nsi\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 26)\n" +
+ " I myI = s -> li; // error - local var of outer class\n" +
+ " ^^\n" +
+ "Cannot make a static reference to the non-static variable li\n" +
+ "----------\n"
+ );
+ }
+
+ public void testBug566518_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " int f = switch (5) {\n"+
+ " case 5: {\n"+
+ " interface I{\n"+
+ " \n"+
+ " }\n"+
+ " class C implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " \n"+
+ " yield new C().j;\n"+
+ " }\n"+
+ " default:\n"+
+ " throw new IllegalArgumentException(\"Unexpected value: \" );\n"+
+ " };\n"+
+ " System.out.println(f);\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}"
+ },
+ "5");
+ }
+
+ public void testBug566518_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " class F {\n"+
+ " int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(new F().create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+ public void testBug566518_003() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public interface X {\n"+
+ " static void foo() {\n"+
+ " class F {\n"+
+ " int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(new F().create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+ public void testBug566518_004() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public interface X {\n"+
+ " static void foo() {\n"+
+ " interface F {\n"+
+ " static int create(int lo) {\n"+
+ " I myI = s -> lo;\n"+
+ " return myI.bar(0);\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(F.create(0));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "\n"+
+ "interface I {\n"+
+ " int bar(int l);\n"+
+ "}"
+ },
+ "0");
+ }
+
+ public void testBug566518_005() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " int f = switch (5) {\n"+
+ " case 5: {\n"+
+ " interface I{\n"+
+ " \n"+
+ " }\n"+
+ " class C implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " \n"+
+ " yield new C().j;\n"+
+ " }\n"+
+ " default:\n"+
+ " throw new IllegalArgumentException(\"Unexpected value: \" );\n"+
+ " };\n"+
+ " System.out.println(f);\n"+
+ " class C1 implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X.foo();\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n"+
+ "1. ERROR in X.java (at line 18)\n"+
+ " class C1 implements I{\n"+
+ " ^\n" +
+ "I cannot be resolved to a type\n"+
+ "----------\n"
+ );
+ }
+
+ public void testBug566518_006() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public enum X {\n"+
+ " A, B, C;\n"+
+ " public void foo() {\n"+
+ " int f = switch (5) {\n"+
+ " case 5: {\n"+
+ " interface I{\n"+
+ " \n"+
+ " }\n"+
+ " class C implements I{\n"+
+ " public int j = 5;\n"+
+ " }\n"+
+ " \n"+
+ " yield new C().j;\n"+
+ " }\n"+
+ " default:\n"+
+ " throw new IllegalArgumentException(\"Unexpected value: \" );\n"+
+ " };\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X x = X.A;\n"+
+ " System.out.println();\n"+
+ " }\n"+
+ "}"
+ },
+ "");
+ }
+ // 6.5.5.1
+ public void testBug566715_001() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " static void foo() {\n"+
+ " interface I {\n"+
+ " X<T> supply();\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n"+
+ "1. WARNING in X.java (at line 3)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " X<T> supply();\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static type T\n" +
+ "----------\n"
+ );
+ }
+ // 6.5.5.1
+ public void testBug566715_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " X<T> supply();\n"+
+ " }\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n"+
+ "1. WARNING in X.java (at line 3)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " X<T> supply();\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static type T\n" +
+ "----------\n"
+ );
+ }
+ // 6.5.5.1
+ public void testBug566715_003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " record R(X<T> x) {}\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " record R(X<T> x) {}\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static type T\n" +
+ "----------\n"
+ );
+ }
+ // 9.1.1/14.3
+ public void testBug566720_001() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " public interface I {}\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " public interface I {}\n" +
+ " ^\n" +
+ "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
+ "----------\n"
+ );
+ }
+ // 9.1.1/14.3
+ public void testBug566720_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " private interface I {}\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " private interface I {}\n" +
+ " ^\n" +
+ "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
+ "----------\n"
+ );
+ }
+ // 9.1.1
+ public void testBug566720_003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " protected interface I {}\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " protected interface I {}\n" +
+ " ^\n" +
+ "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
+ "----------\n"
+ );
+ }
+ // 9.1.1
+ public void testBug566720_004() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " final interface I {}\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " final interface I {}\n" +
+ " ^\n" +
+ "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
+ "----------\n"
+ );
+ }
+ // 9.1.1
+ public void testBug566720_005() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> {\n"+
+ " void foo() {\n"+
+ " static interface I {}\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " static interface I {}\n" +
+ " ^\n" +
+ "Illegal modifier for the local interface I; abstract and strictfp are the only modifiers allowed explicitly \n" +
+ "----------\n"
+ );
+ }
+ public void testBug566748_001() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n"+
+ " int count;\n"+
+ " void doNothing() {}\n"+
+ " void foo1(String s) {\n"+
+ " int i;\n"+
+ " interface I {\n"+
+ " default X<T> bar() {\n"+
+ " if (count > 0 || i > 0 || s == null)\n"+
+ " return null;\n"+
+ " doNothing();\n"+
+ " return null;\n"+
+ " }\n"+
+ " } \n"+
+ " }\n"+
+ " void foo2(String s) {\n"+
+ " try {\n"+
+ " throw new Exception();\n"+
+ " } catch (Exception e) {\n"+
+ " interface I {\n"+
+ " default int bar() {\n"+
+ " return e != null ? 0 : 1;\n"+
+ " }\n"+
+ " } \n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 6)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " default X<T> bar() {\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static type T\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " if (count > 0 || i > 0 || s == null)\n" +
+ " ^^^^^\n" +
+ "Cannot make a static reference to the non-static field count\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " if (count > 0 || i > 0 || s == null)\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static variable i\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 8)\n" +
+ " if (count > 0 || i > 0 || s == null)\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static variable s\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 10)\n" +
+ " doNothing();\n" +
+ " ^^^^^^^^^\n" +
+ "Cannot make a static reference to the non-static method doNothing() from the type X<T>\n" +
+ "----------\n" +
+ "7. WARNING in X.java (at line 19)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 21)\n" +
+ " return e != null ? 0 : 1;\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static variable e\n" +
+ "----------\n"
+ );
+ }
+ public void testBug566748_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X<T> {\n"+
+ " int count = 0;\n"+
+ "\n"+
+ " default void doNothing() {}\n"+
+ "\n"+
+ " default void foo1(String s) {\n"+
+ " int i;\n"+
+ " interface I {\n"+
+ " default X<T> bar() {\n"+
+ " if (count > 0 || i > 0 || s == null)\n"+
+ " return null;\n"+
+ " doNothing();\n"+
+ " return null;\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "\n"+
+ " default void foo2(String s) {\n"+
+ " try {\n"+
+ " throw new Exception();\n"+
+ " } catch (Exception e) {\n"+
+ " interface I { \n"+
+ " default int bar() {\n"+
+ " return e != null ? 0 : 1;\n"+
+ " } \n"+
+ " } \n"+
+ " \n"+
+ " } \n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 8)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " default X<T> bar() {\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static type T\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " if (count > 0 || i > 0 || s == null)\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static variable i\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 10)\n" +
+ " if (count > 0 || i > 0 || s == null)\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static variable s\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 12)\n" +
+ " doNothing();\n" +
+ " ^^^^^^^^^\n" +
+ "Cannot make a static reference to the non-static method doNothing() from the type X<T>\n" +
+ "----------\n" +
+ "6. WARNING in X.java (at line 22)\n" +
+ " interface I { \n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 24)\n" +
+ " return e != null ? 0 : 1;\n" +
+ " ^\n" +
+ "Cannot make a static reference to the non-static variable e\n" +
+ "----------\n"
+ );
+ }
+ // 9.6
+ public void testBug564557AnnotInterface_001() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() {\n"+
+ " class I {\n"+
+ " @interface Annot {\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " @interface Annot {\n" +
+ " ^^^^^\n" +
+ "The member annotation Annot can only be defined inside a top-level class or interface or in a static context\n" +
+ "----------\n"
+ );
+ }
+ // 9.6
+ public void testBug564557AnnotInterface_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " @interface Annot {\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " @interface Annot {\n" +
+ " ^^^^^\n" +
+ "The member annotation Annot can only be defined inside a top-level class or interface or in a static context\n" +
+ "----------\n"
+ );
+ }
+ // 9.4 && 15.12.3
+ public void testBug564557MethodInvocation_003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() {\n"+
+ " Zork();\n"+
+ " interface I {\n"+
+ " default void bar() {}\n"+
+ " default void b1() {\n"+
+ " class J {\n"+
+ " void jb2() {\n"+
+ " bar();\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n"
+ );
+ }
+ // 9.4 && 15.12.3
+ public void testBug564557MethodInvocation_004() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " default void bar() {}\n"+
+ " default void b1() {\n"+
+ " interface J {\n"+
+ " default void jb2() {\n"+
+ " bar();\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 5)\n" +
+ " default void b1() {\n" +
+ " ^^^^\n" +
+ "The method b1() from the type I is never used locally\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 6)\n" +
+ " interface J {\n" +
+ " ^\n" +
+ "The type J is never used locally\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " bar();\n" +
+ " ^^^\n" +
+ "Cannot make a static reference to the non-static method bar() from the type I\n" +
+ "----------\n"
+ );
+ }
+ // 13.1
+ public void testBug564557BinaryForm_005() throws Exception {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(\"\");\n"+
+ " }\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "");
+ String expectedOutput = "abstract static interface X$1I {\n";
+ LocalStaticsTest_15.verifyClassFile(expectedOutput, "X$1I.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // 14.3 for enum
+ public void testBug564557BinaryForm_006() throws Exception {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(\"\");\n"+
+ " }\n"+
+ " void foo() {\n"+
+ " enum I {\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "");
+ String expectedOutput = "static final enum X$1I {\n";
+ LocalStaticsTest_15.verifyClassFile(expectedOutput, "X$1I.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // 15.8.3
+ public void testBug564557thisInStatic_007() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " int count = 0;\n"+
+ " static void bar() {\n"+
+ " int i = this.count;\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 4)\n" +
+ " int count = 0;\n" +
+ " ^^^^^\n" +
+ "The value of the field I.count is not used\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " int i = this.count;\n" +
+ " ^^^^\n" +
+ "Cannot use this in a static context\n" +
+ "----------\n"
+ );
+ }
+ // 15.8.3
+ public void testBug564557thisInStatic_008() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " int count = 0;\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " static void bar() {\n"+
+ " int i = X.this.count;\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " int i = X.this.count;\n" +
+ " ^^^^^^\n" +
+ "No enclosing instance of the type X is accessible in scope\n" +
+ "----------\n"
+ );
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching15Test.java
index 7473aaf0e0..e39f23c842 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching15Test.java
@@ -18,30 +18,30 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import junit.framework.Test;
-public class PatternMatching14Test extends AbstractRegressionTest {
+public class PatternMatching15Test extends AbstractRegressionTest {
- private static final JavacTestOptions JAVAC_OPTIONS = new JavacTestOptions("-source 14 --enable-preview -Xlint:-preview");
+ private static final JavacTestOptions JAVAC_OPTIONS = new JavacTestOptions("-source 15 --enable-preview -Xlint:-preview");
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug562392" };
+// TESTS_NAMES = new String[] { "test025b" };
}
public static Class<?> testClass() {
- return PatternMatching14Test.class;
+ return PatternMatching15Test.class;
}
public static Test suite() {
- return buildMinimalComplianceTestSuite(testClass(), F_14);
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
}
- public PatternMatching14Test(String testName){
+ public PatternMatching15Test(String testName){
super(testName);
}
// Enables the tests to run individually
protected Map<String, String> getCompilerOptions(boolean preview) {
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews,
preview ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
@@ -50,6 +50,8 @@ public class PatternMatching14Test extends AbstractRegressionTest {
@Override
protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
+ if(!isJRE15Plus)
+ return;
runConformTest(testFiles, expectedOutput, customOptions, new String[] {"--enable-preview"}, JAVAC_OPTIONS);
}
protected void runNegativeTest(
@@ -67,6 +69,62 @@ public class PatternMatching14Test extends AbstractRegressionTest {
runner.expectedJavacOutputString = javacLog;
runner.runNegativeTest();
}
+ public void test000a() {
+ Map<String, String> options = getCompilerOptions(false);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
+ runNegativeTest(
+ new String[] {
+ "X1.java",
+ "public class X1 {\n" +
+ " public void foo(Object obj) {\n" +
+ " if (obj instanceof String s) {\n" +
+ " }\n " +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X1.java (at line 3)\n" +
+ " if (obj instanceof String s) {\n" +
+ " ^^^^^^^^\n" +
+ "The preview feature Pattern Matching in instanceof Expressions is only available with source level 15 and above\n" +
+ "----------\n",
+ null,
+ true,
+ options);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
+ }
+ public void test000b() {
+ Map<String, String> options = getCompilerOptions(true);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
+ runNegativeTest(
+ new String[] {
+ "X1.java",
+ "public class X1 {\n" +
+ " public void foo(Object obj) {\n" +
+ " if (obj instanceof String s) {\n" +
+ " }\n " +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X1.java (at line 0)\n" +
+ " public class X1 {\n" +
+ " ^\n" +
+ "Preview features enabled at an invalid source release level 14, preview can be enabled only at source level 15\n" +
+ "----------\n",
+ null,
+ true,
+ options);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
+ }
public void test001() {
Map<String, String> options = getCompilerOptions(false);
runNegativeTest(
@@ -83,7 +141,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X1.java (at line 3)\n" +
" if (obj instanceof String s) {\n" +
" ^^^^^^^^\n" +
- "Instanceof Pattern is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "Pattern Matching in instanceof Expressions is a preview feature and disabled by default. Use --enable-preview to enable\n" +
"----------\n",
/* omit one arg to directly call super method without JAVA_OPTIONS */
null,
@@ -260,12 +318,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X6a.java (at line 8)\n" +
" System.out.print(i);\n" +
" ^\n" +
- "The pattern variable i is not in scope in this location\n" +
+ "i cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X6a.java (at line 11)\n" +
" System.out.print(i);\n" +
" ^\n" +
- "The pattern variable i is not in scope in this location\n" +
+ "i cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -298,12 +356,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X6b.java (at line 8)\n" +
" System.out.print(i);\n" +
" ^\n" +
- "The pattern variable i is not in scope in this location\n" +
+ "i cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X6b.java (at line 11)\n" +
" System.out.print(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -333,7 +391,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X6c.java (at line 7)\n" +
" System.out.print(i);\n" +
" ^\n" +
- "The pattern variable i is not in scope in this location\n" +
+ "i cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -363,7 +421,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X6d.java (at line 7)\n" +
" System.out.print(i);\n" +
" ^\n" +
- "The pattern variable i is not in scope in this location\n" +
+ "i cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -393,7 +451,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X7.java (at line 7)\n" +
" System.out.print(i);\n" +
" ^\n" +
- "The pattern variable i is not in scope in this location\n" +
+ "i cannot be resolved to a variable\n" +
"----------\n",
"X7.java:4: warning: [preview] pattern matching in instanceof is a preview feature and may be removed in a future release.\n" +
" if (obj instanceof Integer i) {\n" +
@@ -514,7 +572,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X11.java (at line 7)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -549,7 +607,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X12.java (at line 11)\n" +
" s = null;\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -580,15 +638,10 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"}\n",
},
"----------\n" +
- "1. WARNING in X13.java (at line 7)\n" +
- " System.out.println(\"s:\" + s);\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Dead code\n" +
- "----------\n" +
- "2. ERROR in X13.java (at line 9)\n" +
+ "1. ERROR in X13.java (at line 9)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -618,7 +671,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X14.java (at line 5)\n" +
" System.out.print(\"then:\" + s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -648,7 +701,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X14a.java (at line 5)\n" +
" System.out.print(\"then:\" + s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -678,7 +731,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X14b.java (at line 7)\n" +
" System.out.print(\"else:\" + s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -708,7 +761,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X14c.java (at line 7)\n" +
" System.out.print(\"else:\" + s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -838,7 +891,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X15b.java (at line 9)\n" +
" System.out.print(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -884,7 +937,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X17.java (at line 5)\n" +
" System.out.print(s[0]);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1006,12 +1059,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X21.java (at line 5)\n" +
" System.out.print(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X21.java (at line 6)\n" +
" System.out.print(s2);\n" +
" ^^\n" +
- "The pattern variable s2 is not in scope in this location\n" +
+ "s2 cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1063,17 +1116,17 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X22a.java (at line 8)\n" +
" o = s.substring(0, s.length() - 1);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n" +
"2. ERROR in X22a.java (at line 8)\n" +
" o = s.substring(0, s.length() - 1);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n" +
"3. ERROR in X22a.java (at line 9)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
null,
true,
@@ -1101,7 +1154,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X22b.java (at line 10)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
null,
true,
@@ -1152,12 +1205,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X23.java (at line 7)\n" +
" while (!(o instanceof String s) && s.length() > 0) {\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n" +
"2. ERROR in X23.java (at line 8)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1186,12 +1239,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X23a.java (at line 8)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X23a.java (at line 10)\n" +
" } while (!(o instanceof String s) && s.length() > 0);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n",
"",
null,
@@ -1222,12 +1275,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X23b.java (at line 7)\n" +
" while (!(o instanceof String s) && s.length() > 0) {\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n" +
"2. ERROR in X23b.java (at line 8)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1257,12 +1310,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X23c.java (at line 8)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X23c.java (at line 10)\n" +
" }while (!(o instanceof String s) && s.length() > 0);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n",
"",
null,
@@ -1336,7 +1389,143 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X25.java (at line 8)\n" +
" System.out.print(\"s:\" + s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
+ "----------\n",
+ "",
+ null,
+ true,
+ options);
+ }
+ public void test025a() {
+ Map<String, String> options = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X25.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class X25 {\n" +
+ " public static void main(String[] o) {\n" +
+ " foo(\"one\");\n" +
+ " }\n" +
+ " public static void foo(Object o) {\n" +
+ " if ( (o instanceof String a) || (! (o instanceof String a)) ) {\n" +
+ " System.out.print(\"a:\" + a);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X25.java (at line 8)\n" +
+ " System.out.print(\"a:\" + a);\n" +
+ " ^\n" +
+ "a cannot be resolved to a variable\n" +
+ "----------\n",
+ "",
+ null,
+ true,
+ options);
+ }
+ public void test025b() {
+ Map<String, String> options = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X25.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class X25 {\n" +
+ " public static void main(String[] o) {\n" +
+ " foo(\"one\");\n" +
+ " }\n" +
+ " public static void foo(Object o) {\n" +
+ " if ( (o instanceof String a) || (! (o instanceof String a)) ) {\n" +
+ " System.out.println(\"none\");\n" +
+ " } else {\n" +
+ " System.out.print(\"a:\" + a);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "none",
+ options);
+ }
+ public void test025c() {
+ Map<String, String> options = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X25.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class X25 {\n" +
+ " public static void main(String[] o) {\n" +
+ " foo(\"one\", new Integer(0));\n" +
+ " }\n" +
+ " public static void foo(Object o, Object p) {\n" +
+ " if ( (o instanceof String a) || (! (p instanceof String a)) ) {\n" +
+ " System.out.println(\"none\");\n" +
+ " } else {\n" +
+ " System.out.print(\"a:\" + a);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "none",
+ options);
+ }
+ /*
+ * It's not allowed to have two pattern variables with same name in the
+ * same scope
+ */
+ public void test026() {
+ Map<String, String> options = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X26.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class X26 {\n" +
+ " public static void main(String[] o) {\n" +
+ " foo(\"one\", \"two\");\n" +
+ " }\n" +
+ " public static void foo(Object o, Object p) {\n" +
+ " if ((o instanceof String s) && (p instanceof String s)) {\n" +
+ " System.out.print(\"s:\" + s);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X26.java (at line 7)\n" +
+ " if ((o instanceof String s) && (p instanceof String s)) {\n" +
+ " ^\n" +
+ "Duplicate local variable s\n" +
+ "----------\n",
+ "",
+ null,
+ true,
+ options);
+ }
+ /*
+ * It's not allowed to have two pattern variables with same name in the
+ * same scope
+ */
+ public void test026a() {
+ Map<String, String> options = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X26.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class X26 {\n" +
+ " public static void main(String[] o) {\n" +
+ " foo(\"one\", \"two\");\n" +
+ " }\n" +
+ " public static void foo(Object o, Object p) {\n" +
+ " if ((o instanceof String s) && (!(o instanceof String s))) {\n" +
+ " System.out.print(\"s:\" + s);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X26.java (at line 7)\n" +
+ " if ((o instanceof String s) && (!(o instanceof String s))) {\n" +
+ " ^\n" +
+ "Duplicate local variable s\n" +
"----------\n",
"",
null,
@@ -1347,7 +1536,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
* It's not a problem to define the same var in two operands of a binary expression,
* but then it is not in scope below.
*/
- public void test026() {
+ public void test026b() {
Map<String, String> options = getCompilerOptions(true);
runNegativeTest(
new String[] {
@@ -1368,7 +1557,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X26.java (at line 8)\n" +
" System.out.print(\"s:\" + s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1456,7 +1645,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X30.java (at line 8)\n" +
" System.out.print(s.charAt(i));\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n",
"",
null,
@@ -1483,17 +1672,17 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X31.java (at line 7)\n" +
" for(int i = 0; !(obj instanceof String[] s) && s.length > 0 && i < s.length; i++) {\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X31.java (at line 7)\n" +
" for(int i = 0; !(obj instanceof String[] s) && s.length > 0 && i < s.length; i++) {\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n" +
"3. ERROR in X31.java (at line 8)\n" +
" System.out.println(s[i]);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1552,7 +1741,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X33.java (at line 12)\n" +
" res = s.substring(1);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved\n" +
"----------\n",
"",
null,
@@ -1622,12 +1811,12 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X35.java (at line 11)\n" +
" yield s;\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n" +
"2. ERROR in X35.java (at line 14)\n" +
" yield s;\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
@@ -1706,16 +1895,13 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"1. ERROR in X38.java (at line 10)\n" +
" System.out.println(s);\n" +
" ^\n" +
- "The pattern variable s is not in scope in this location\n" +
+ "s cannot be resolved to a variable\n" +
"----------\n",
"",
null,
true,
getCompilerOptions(true));
}
- /*
- * Failing with VerifyError
- */
public void test039() {
runConformTest(
new String[] {
@@ -1813,7 +1999,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"else_x",
getCompilerOptions(true));
}
- public void _test043() {
+ public void test043() {
runConformTest(
new String[] {
"X43.java",
@@ -1826,11 +2012,11 @@ public class PatternMatching14Test extends AbstractRegressionTest {
" class Inner {\n" +
" public boolean foo(Object obj) {\n" +
" if (obj instanceof String s) {\n" +
- " // x is shadowed now\n" +
+ " // s is shadowed now\n" +
" if (!\"foo\".equals(s))\n" +
" return false;\n" +
" }\n" +
- " // x is not shadowed\n" +
+ " // s is not shadowed\n" +
" return \"test\".equals(s);\n" +
" }\n" +
" }\n" +
@@ -1838,7 +2024,7 @@ public class PatternMatching14Test extends AbstractRegressionTest {
" }\n" +
"}\n",
},
- "else_x",
+ "true",
getCompilerOptions(true));
}
public void test044() {
@@ -2671,4 +2857,339 @@ public class PatternMatching14Test extends AbstractRegressionTest {
"PASS",
compilerOptions);
}
+ public void test062() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public void foo(Object o) {\n"+
+ " int len = (o instanceof String p) ? test(p -> p.length()) : test(p -> p.length());\n"+
+ " }\n"+
+ " public int test(FI fi) {\n" +
+ " return fi.length(\"\");\n" +
+ " } \n" +
+ " interface FI {\n" +
+ " public int length(String str);\n" +
+ " }" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " int len = (o instanceof String p) ? test(p -> p.length()) : test(p -> p.length());\n" +
+ " ^\n" +
+ "Lambda expression\'s parameter p cannot redeclare another local variable defined in an enclosing scope. \n" +
+ "----------\n",
+ "",
+ null,
+ true,
+ compilerOptions);
+ }
+ // Same as above, but pattern variable in scope in false of conditional expression
+ public void test063() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public void foo(Object o) {\n"+
+ " int len = !(o instanceof String p) ? test(p -> p.length()) : test(p -> p.length());\n"+
+ " }\n"+
+ " public int test(FI fi) {\n" +
+ " return fi.length(\"\");\n" +
+ " } \n" +
+ " interface FI {\n" +
+ " public int length(String str);\n" +
+ " }" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " int len = !(o instanceof String p) ? test(p -> p.length()) : test(p -> p.length());\n" +
+ " ^\n" +
+ "Lambda expression\'s parameter p cannot redeclare another local variable defined in an enclosing scope. \n" +
+ "----------\n",
+ "",
+ null,
+ true,
+ compilerOptions);
+ }
+ public void test064() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"+
+ " public static void main(String argv[]) {\n" +
+ " System.out.println(new X().foo(\"foo\", \"test\"));\n" +
+ " }\n" +
+ " public boolean foo(Object obj, String s) {\n" +
+ " class Inner {\n" +
+ " public boolean foo(Object obj) {\n" +
+ " if (obj instanceof String s) {\n" +
+ " // s is shadowed now\n" +
+ " if (\"foo\".equals(s))\n" +
+ " return false;\n" +
+ " } else if (obj instanceof String s) { \n" +
+ " }\n"+
+ " // s is not shadowed\n" +
+ " return \"test\".equals(s);\n" +
+ " }\n" +
+ " }\n" +
+ " return new Inner().foo(obj);\n" +
+ " }" +
+ "}",
+ },
+ "false",
+ compilerOptions);
+ }
+ public void test065() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"+
+ " public static void main(String argv[]) {\n"
+ + " new X().foo(\"foo\");\n"
+ + " }\n"
+ + " public void foo(Object o) {\n"
+ + " if ((o instanceof String s)) {\n"
+ + " System.out.println(\"if:\" + s);\n"
+ + " } else {\n"
+ + " throw new IllegalArgumentException();\n"
+ + " }\n"
+ + " System.out.println(\"after:\" + s);\n"
+ + " }" +
+ "}",
+ },
+ "if:foo\n" +
+ "after:foo",
+ compilerOptions);
+ }
+ public void test066() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " protected Object x = \"FIELD X\";\n"
+ + " public void f(Object obj, boolean b) {\n"
+ + " if ((x instanceof String x)) {\n"
+ + " System.out.println(x.toLowerCase());\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " new X().f(Integer.parseInt(\"1\"), false);\n"
+ + " }\n"
+ + "}",
+ },
+ "field x",
+ compilerOptions);
+ }
+ public void test067() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " protected String x = \"FIELD X\";\n"
+ + " public void f(Object obj, boolean b) {\n"
+ + " if ((x instanceof String x) && x.length() > 0) {\n"
+ + " System.out.println(x.toLowerCase());\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " new X().f(Integer.parseInt(\"1\"), false);\n"
+ + " }\n"
+ + "}",
+ },
+ "field x",
+ compilerOptions);
+ }
+ public void test068() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " if (o instanceof X x || o instanceof X) {\n"
+ + " System.out.println(\"X\");\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "X",
+ compilerOptions);
+ }
+ public void test069() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " if (o instanceof X x && x instanceof X x) {\n"
+ + " System.out.println(\"X\");\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " if (o instanceof X x && x instanceof X x) {\n" +
+ " ^\n" +
+ "Duplicate local variable x\n" +
+ "----------\n",
+ null,
+ true,
+ compilerOptions);
+ }
+ // Javac rejects this. Need to check with the spec authors
+ public void test070() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " if (o instanceof X x || o instanceof X x) {\n"
+ + " System.out.println(\"X\");\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "X",
+ compilerOptions);
+ }
+ // Javac rejects the code on the IF itself (same as above)
+ public void test071() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " if (o instanceof X x || o instanceof X x) {\n"
+ + " System.out.println(x);\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " System.out.println(x);\n" +
+ " ^\n" +
+ "x cannot be resolved to a variable\n" +
+ "----------\n",
+ null,
+ true,
+ compilerOptions);
+ }
+ // Javac rejects the code on the IF itself (same as above)
+ public void test072() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " if (o instanceof X x || o instanceof X x) {\n"
+ + " throw new IllegalArgumentException();\n"
+ + " }\n"
+ + " System.out.println(x);\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " System.out.println(x);\n" +
+ " ^\n" +
+ "x cannot be resolved to a variable\n" +
+ "----------\n",
+ null,
+ true,
+ compilerOptions);
+ }
+ public void test073() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " try {\n"
+ + " if (!(o instanceof X x) || x != null || x!= null) { // allowed \n"
+ + " throw new IllegalArgumentException();\n"
+ + " }\n"
+ + " System.out.println(x); // allowed \n"
+ + " } catch (Throwable e) {\n"
+ + " e.printStackTrace(System.out);\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "java.lang.IllegalArgumentException\n" +
+ " at X.foo(X.java:6)\n" +
+ " at X.main(X.java:14)",
+ compilerOptions);
+ }
+ public void test074() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "@SuppressWarnings(\"preview\")\n"+
+ "public class X {\n"
+ + " static void foo(Object o) {\n"
+ + " if (!(o instanceof X x) || x != null || x!= null) {\n"
+ + " System.out.println(x);\n // not allowed"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " public static void main(String[] args) {\n"
+ + " foo(new X());\n"
+ + " }\n"
+ + "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " System.out.println(x);\n" +
+ " ^\n" +
+ "x cannot be resolved to a variable\n" +
+ "----------\n",
+ null,
+ true,
+ compilerOptions);
+ }
}
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 8aa63ad5af..9031689c0d 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
@@ -29,14 +29,14 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug564146"};
+// TESTS_NAMES = new String[] { "testBug566418_001"};
}
public static Class<?> testClass() {
return RecordsRestrictedClassTest.class;
}
public static Test suite() {
- return buildMinimalComplianceTestSuite(testClass(), F_14);
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
}
public RecordsRestrictedClassTest(String testName){
super(testName);
@@ -45,9 +45,9 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
// Enables the tests to run individually
protected Map<String, String> getCompilerOptions() {
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14); // FIXME
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15); // FIXME
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
defaultOptions.put(CompilerOptions.OPTION_Store_Annotations, CompilerOptions.ENABLED);
@@ -59,20 +59,19 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
runConformTest(testFiles, expectedOutput, getCompilerOptions());
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
@Override
- protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions) {
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
Runner runner = new Runner();
runner.testFiles = testFiles;
runner.expectedOutputString = expectedOutput;
runner.vmArguments = new String[] {"--enable-preview"};
runner.customOptions = customOptions;
- runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("14");
+ runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("15");
runner.runConformTest();
}
@Override
protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
- runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("14"));
+ runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("15"));
}
protected void runWarningTest(String[] testFiles, String expectedCompilerLog) {
runWarningTest(testFiles, expectedCompilerLog, null);
@@ -88,8 +87,8 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
runner.expectedCompilerLog = expectedCompilerLog;
runner.customOptions = customOptions;
runner.vmArguments = new String[] {"--enable-preview"};
- runner.javacTestOptions = javacAdditionalTestOptions == null ? JavacTestOptions.forReleaseWithPreview("14") :
- JavacTestOptions.forReleaseWithPreview("14", javacAdditionalTestOptions);
+ runner.javacTestOptions = javacAdditionalTestOptions == null ? JavacTestOptions.forReleaseWithPreview("15") :
+ JavacTestOptions.forReleaseWithPreview("15", javacAdditionalTestOptions);
runner.runWarningTest();
}
@@ -429,7 +428,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 7)\n" +
" private Point {\n" +
" ^^^^^\n" +
- "The canonical constructor Point of a record declaration must be declared public.\n" +
+ "Cannot reduce the visibility of a canonical constructor Point from that of the record\n" +
"----------\n");
}
public void testBug550750_020() {
@@ -449,31 +448,17 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"}\n" +
"interface I {}\n"
},
- "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " protected Point {\n" +
- " ^^^^^\n" +
- "The canonical constructor Point of a record declaration must be declared public.\n" +
- "----------\n");
- }
- public void testBug550750_021() {
- runConformTest(
- new String[] {
- "X.java",
- "public class X {\n"+
- " public static void main(String[] args){\n"+
- " System.out.println(0);\n" +
- " }\n"+
- "}\n"+
- "record Point(int myInt, char myChar) implements I {\n"+
- " public Point {\n"+
- " this.myInt = myInt;\n" +
- " this.myChar = myChar;\n" +
- " }\n"+
- "}\n" +
- "interface I {}\n"
- },
- "0");
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " this.myInt = myInt;\n" +
+ " ^^^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myInt in compact constructor\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " this.myChar = myChar;\n" +
+ " ^^^^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myChar in compact constructor\n" +
+ "----------\n");
}
public void testBug550750_022() {
this.runNegativeTest(
@@ -633,6 +618,16 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
" static final int z;\n" +
" ^\n" +
"The blank final field z may not have been initialized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " this.myInt = myInt;\n" +
+ " ^^^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myInt in compact constructor\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " this.myZ = myZ;\n" +
+ " ^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myZ in compact constructor\n" +
"----------\n");
}
public void testBug550750_028() {
@@ -742,7 +737,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 1)\n" +
" class record {\n" +
" ^^^^^^\n" +
- "Record is a restricted identifier and hence not a valid type name\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n");
}
public void testBug550750_033() {
@@ -759,7 +754,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 1)\n" +
" class X<record> {\n" +
" ^^^^^^\n" +
- "Record is a restricted identifier and hence not a valid type name\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n");
}
public void testBug550750_034() {
@@ -777,7 +772,12 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 5)\n" +
" public <record> void foo(record args){}\n" +
" ^^^^^^\n" +
- "Record is a restricted identifier and hence not a valid type name\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " public <record> void foo(record args){}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n");
}
public void testBug550750_035() {
@@ -795,12 +795,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 5)\n" +
" public void foo(record args){}\n" +
" ^^^^^^\n" +
- "record cannot be resolved to a type\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
- " public void foo(record args){}\n" +
- " ^^^^^^\n" +
- "Record is a restricted identifier and hence not a valid type name\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n");
}
public void testBug550750_036() {
@@ -826,12 +821,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"2. ERROR in X.java (at line 4)\n" +
" I lambda = (record r) -> {};\n" +
" ^^^^^^\n" +
- "record cannot be resolved to a type\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 4)\n" +
- " I lambda = (record r) -> {};\n" +
- " ^^^^^^\n" +
- "Record is a restricted identifier and hence not a valid type name\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n");
}
public void testBug550750_037() {
@@ -1105,14 +1095,24 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
" ^^^^^\n" +
"Duplicate method Point(Integer, int) in type Point\n" +
"----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " this.myInt = 0;\n" +
+ " ^^^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myInt in compact constructor\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 9)\n" +
+ " this.myZ = 0;\n" +
+ " ^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myZ in compact constructor\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 11)\n" +
" public Point(Integer myInt, int myZ) {\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Duplicate method Point(Integer, int) in type Point\n" +
"----------\n");
}
public void testBug553152_009() {
- this.runNegativeTest(
+ this.runConformTest(
new String[] {
"X.java",
"public class X {\n"+
@@ -1128,12 +1128,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"}\n" +
"interface I {}\n"
},
- "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " Point(Integer myInt, int myZ) {\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "The canonical constructor Point of a record declaration must be declared public.\n" +
- "----------\n");
+ "0");
}
public void testBug553152_010() {
this.runNegativeTest(
@@ -1336,7 +1331,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"Nested Record is (implicitly) static and hence enclosing type should be static\n" +
"----------\n");
}
- public void _testBug553152_018() {
+ public void testBug553152_018() {
runConformTest(
new String[] {
"X.java",
@@ -1376,25 +1371,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest {
"The accessor method must not be static\n" +
"----------\n");
}
-public void testBug553153_01() {
- runConformTest(
- new String[] {
- "X.java",
- "public class X {\n"+
- " public static void main(String[] args){\n"+
- " System.out.println(0);\n" +
- " }\n"+
- "}\n"+
- "record Point(int myInt, char myChar) implements I {\n"+
- " public Point {\n"+
- " this.myInt = myInt;\n" +
- " }\n"+
- "}\n" +
- "interface I {}\n"
- },
- "0");
- }
- public void testBug553153_002() {
+public void testBug553153_002() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -1413,10 +1390,20 @@ public void testBug553153_01() {
"interface I {}\n"
},
"----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " public Point {\n" +
- " ^^^^^\n" +
- "The blank final field myChar may not have been initialized\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " this.myInt = myInt;\n" +
+ " ^^^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myInt in compact constructor\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " if (this.myInt > 0) // conditional assignment\n" +
+ " ^^^^^\n" +
+ "The blank final field myInt may not have been initialized\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " this.myChar = myChar;\n" +
+ " ^^^^^^^^^^^\n" +
+ "Illegal explicit assignment of a final field myChar in compact constructor\n" +
"----------\n");
}
public void testBug553153_003() {
@@ -1431,7 +1418,6 @@ public void testBug553153_003() {
"record Point(int myInt, char myChar) implements I {\n"+
" static int f;\n"+
" public Point {\n"+
- " this.myInt = myInt;\n" +
" }\n"+
"}\n" +
"interface I {}\n"
@@ -2337,7 +2323,7 @@ public void testBug560893_006() {
"X.java",
"class X {\n"+
" public static void main(String[] args) {\n"+
- " static record R(int x, int y) {}\n"+
+ " record R(int x, int y) {}\n"+
" R r = new R(100,200);\n"+
" System.out.println(r.x());\n"+
" }\n"+
@@ -2371,7 +2357,7 @@ public void testBug560893_007() {
"1. ERROR in X.java (at line 10)\n" +
" System.out.println(li); // error, local variable\n" +
" ^^\n" +
- "Cannot make a static reference to the non-static variable li from a local record\n" +
+ "Cannot make a static reference to the non-static variable li\n" +
"----------\n" +
"2. ERROR in X.java (at line 11)\n" +
" System.out.println(nsi); // error, non-static member\n" +
@@ -2392,7 +2378,7 @@ public void testBug558718_001() {
"1. ERROR in X.java (at line 1)\n" +
" record R() {}\n" +
" ^^^^^^\n" +
- "record is a preview feature and disabled by default. Use --enable-preview to enable\n" +
+ "Records is a preview feature and disabled by default. Use --enable-preview to enable\n" +
"----------\n",
null,
true,
@@ -2413,7 +2399,7 @@ public void testBug558718_002() {
"1. ERROR in X.java (at line 1)\n" +
" record R() {}\n" +
" ^^^^^^\n" +
- "Syntax error on token \"record\", @ expected\n" +
+ "The preview feature Records is only available with source level 15 and above\n" +
"----------\n" +
"2. ERROR in X.java (at line 1)\n" +
" record R() {}\n" +
@@ -2425,6 +2411,22 @@ public void testBug558718_002() {
options
);
}
+public void testBug56180_001() throws Exception {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "record R () {} \n"+
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(new R().toString());\n"+
+ " }\n"+
+ "}\n"
+ },
+ "R[]");
+ String expectedOutput =
+ " public final java.lang.String toString();\n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "R.class", ClassFileBytesDisassembler.SYSTEM);
+}
public void testBug561528_001() {
runConformTest(
new String[] {
@@ -3279,6 +3281,10 @@ public void testBug562439_013() throws IOException, ClassFormatException {
" RuntimeInvisibleAnnotations: \n" +
" #8 @RCMU(\n" +
" )\n" +
+ " RuntimeInvisibleTypeAnnotations: \n" +
+ " #8 @RCMU(\n" +
+ " target type = 0x14 METHOD_RETURN\n" +
+ " )\n" +
" \n";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
@@ -3392,9 +3398,11 @@ public void testBug562439_015() throws IOException, ClassFormatException {
" 4 ireturn\n" +
" Line numbers:\n" +
" [pc: 0, line: 11]\n" +
- " RuntimeInvisibleAnnotations: \n" +
+ " RuntimeInvisibleTypeAnnotations: \n" +
" #8 @T(\n" +
- " )\n";
+ " target type = 0x14 METHOD_RETURN\n" +
+ " )\n" +
+ " ";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
"Record: #Record\n" +
@@ -3408,7 +3416,7 @@ public void testBug562439_015() throws IOException, ClassFormatException {
" )\n";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
- " public Point(int myInt, char myChar);\n" +
+ " Point(int myInt, char myChar);\n" +
" 0 aload_0 [this]\n" +
" 1 invokespecial java.lang.Record() [14]\n" +
" 4 aload_0 [this]\n" +
@@ -3471,10 +3479,11 @@ public void testBug562439_016() throws IOException, ClassFormatException {
" 4 ireturn\n" +
" Line numbers:\n" +
" [pc: 0, line: 13]\n" +
- " RuntimeVisibleAnnotations: \n" +
+ " RuntimeVisibleTypeAnnotations: \n" +
" #8 @T(\n" +
+ " target type = 0x14 METHOD_RETURN\n" +
" )\n" +
- " \n";
+ " ";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
"Record: #Record\n" +
@@ -3488,7 +3497,7 @@ public void testBug562439_016() throws IOException, ClassFormatException {
" )\n";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
- " public Point(int myInt, char myChar);\n" +
+ " Point(int myInt, char myChar);\n" +
" 0 aload_0 [this]\n" +
" 1 invokespecial java.lang.Record() [14]\n" +
" 4 aload_0 [this]\n" +
@@ -3533,7 +3542,7 @@ public void testBug562439_017() throws IOException, ClassFormatException {
},
"100");
String expectedOutput =
- " public Point(int myInt, char myChar);\n" +
+ " Point(int myInt, char myChar);\n" +
" 0 aload_0 [this]\n" +
" 1 invokespecial java.lang.Record() [14]\n" +
" 4 aload_0 [this]\n" +
@@ -3591,7 +3600,7 @@ public void testBug562439_018() throws IOException, ClassFormatException {
},
"100");
String expectedOutput =
- " public Point(int myInt, char myChar);\n" +
+ " Point(int myInt, char myChar);\n" +
" 0 aload_0 [this]\n" +
" 1 invokespecial java.lang.Record() [14]\n" +
" 4 aload_0 [this]\n" +
@@ -3657,7 +3666,7 @@ public void testBug562439_019() throws IOException, ClassFormatException {
" \n";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
- " public Point(int myInt, char myChar);\n" +
+ " Point(int myInt, char myChar);\n" +
" 0 aload_0 [this]\n" +
" 1 invokespecial java.lang.Record() [16]\n" +
" 4 aload_0 [this]\n" +
@@ -3697,7 +3706,11 @@ public void testBug562439_019() throws IOException, ClassFormatException {
" RuntimeInvisibleAnnotations: \n" +
" #8 @Annot(\n" +
" )\n" +
- " \n";
+ " RuntimeInvisibleTypeAnnotations: \n" +
+ " #8 @Annot(\n" +
+ " target type = 0x14 METHOD_RETURN\n" +
+ " )\n" +
+ " ";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
expectedOutput =
"Record: #Record\n" +
@@ -3738,7 +3751,7 @@ public void testBug562439_020() throws IOException, ClassFormatException {
},
"100");
String expectedOutput =
- " public Point(int myInt, char myChar);\n" +
+ " Point(int myInt, char myChar);\n" +
" 0 aload_0 [this]\n" +
" 1 invokespecial java.lang.Record() [14]\n" +
" 4 aload_0 [this]\n" +
@@ -3772,136 +3785,3818 @@ public void testBug562439_020() throws IOException, ClassFormatException {
" )\n";
RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
}
-public void testBug564146_001() {
+public void testBug563178_001() {
this.runNegativeTest(
new String[] {
"X.java",
- "public record X(int i) {\n"+
- " public X() {\n"+
- " this.i = 10;\n"+
+ "class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"+
+ "record Point(final int x, int y){\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " record Point(final int x, int y){\n" +
+ " ^\n" +
+ "A record component x cannot have modifiers\n" +
+ "----------\n");
+}
+public void testBug563183_001() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " public X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_002() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " public X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " protected X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
" }\n"+
"}",
},
"----------\n" +
"1. ERROR in X.java (at line 2)\n" +
- " public X() {\n" +
- " ^^^\n" +
- "A non-canonical constructor must start with an explicit invocation to a constructor\n" +
+ " protected X() {}\n" +
+ " ^^^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
"----------\n");
}
-public void testBug564146_002() {
+public void testBug563183_004() {
this.runNegativeTest(
new String[] {
"X.java",
- "public record X(int i) {\n"+
- " public X() {\n"+
- " super();\n"+
- " this.i = 10;\n"+
+ "public record X() {\n"+
+ " protected X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
" }\n"+
"}",
},
"----------\n" +
"1. ERROR in X.java (at line 2)\n" +
- " public X() {\n" +
- " ^^^\n" +
- "A non-canonical constructor must start with an explicit invocation to a constructor\n" +
+ " protected X {}\n" +
+ " ^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
"----------\n");
}
-public void testBug564146_003() {
+public void testBug563183_005() {
this.runNegativeTest(
new String[] {
"X.java",
- "public record X(int i) {\n"+
- " public X(int i) {\n"+
- " this.i = 10;\n"+
- " Zork();\n"+
+ "public record X() {\n"+
+ " /*package */ X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
" }\n"+
"}",
},
"----------\n" +
- "1. ERROR in X.java (at line 4)\n" +
- " Zork();\n" +
- " ^^^^\n" +
- "The method Zork() is undefined for the type X\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " /*package */ X() {}\n" +
+ " ^^^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
"----------\n");
}
-public void testBug564146_004() {
- runConformTest(
+public void testBug563183_006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " /*package */ X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " /*package */ X {}\n" +
+ " ^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_007() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " private X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " private X() {}\n" +
+ " ^^^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_008() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " private X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " private X {}\n" +
+ " ^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_009() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " public R() {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_010() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " public R {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_011() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " protected R() {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_012() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " protected R {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_013() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " /*package */ R() {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " /*package */ R() {}\n" +
+ " ^^^\n" +
+ "Cannot reduce the visibility of a canonical constructor R from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_014() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " /*package */ R {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " /*package */ R {}\n" +
+ " ^\n" +
+ "Cannot reduce the visibility of a canonical constructor R from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_015() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " private R() {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " private R() {}\n" +
+ " ^^^\n" +
+ "Cannot reduce the visibility of a canonical constructor R from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_016() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " protected record R() {\n"+
+ " private R {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " private R {}\n" +
+ " ^\n" +
+ "Cannot reduce the visibility of a canonical constructor R from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_017() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "/*package */ record X() {\n"+
+ " public X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_018() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "/*package */ record X() {\n"+
+ " public X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_019() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "record X() {\n"+
+ " protected X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_020() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "record X() {\n"+
+ " protected X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_021() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ " record X() {\n"+
+ " /*package */ X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_022() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ " record X() {\n"+
+ " /*package */ X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_023() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X() {\n"+
+ " private X() {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " private X() {}\n" +
+ " ^^^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_024() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X() {\n"+
+ " private X {}\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " private X {}\n" +
+ " ^\n" +
+ "Cannot reduce the visibility of a canonical constructor X from that of the record\n" +
+ "----------\n");
+}
+public void testBug563183_025() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record R() {\n"+
+ " public R() {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_026() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record R() {\n"+
+ " protected R {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_027() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record R() {\n"+
+ " /* package */ R() {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563183_028() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record R() {\n"+
+ " private R {}\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug563184_001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X(int angel) {\n"+
+ " X(int devil) {\n"+
+ " this.angel = devil;\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " X(int devil) {\n" +
+ " ^^^^^\n" +
+ "Illegal parameter name devil in canonical constructor, expected angel, the corresponding component name\n" +
+ "----------\n");
+}
+public void testBug563184_002() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "record X(int myInt) {\n"+
+ " X(int myInt) {\n"+
+ " this.myInt = myInt;\n" +
+ " }\n"+
+ " X(int i, int j) {\n"+
+ " this(i);\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}",
+ },
+ "0");
+}
+public void testBug562637_001() {
+ this.runConformTest(
new String[] {
"X.java",
"public record X(int i) {\n"+
+ " public X {\n"+
+ " i = i/2;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(new X(10).i());\n"+
+ " }\n"+
+ "}",
+ },
+ "5");
+}
+ public void testBug563181_01() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.lang.annotation.ElementType;\n"+
+ "import java.lang.annotation.Target;\n"+
+ "public class X { \n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"+
+ "record Point(@RCMU int myInt, char myChar) { \n"+
+ " public int myInt(){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ "} \n"+
+ "@Target({ ElementType.RECORD_COMPONENT, ElementType.METHOD, ElementType.TYPE_USE})\n"+
+ "@interface RCMU {}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Method descriptor #25 ()I\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " public int myInt();\n" +
+ " 0 aload_0 [this]\n" +
+ " 1 getfield Point.myInt : int [17]\n" +
+ " 4 ireturn\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 8]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: Point\n" +
+ " \n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug563181_02() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.lang.annotation.ElementType;\n"+
+ "import java.lang.annotation.Target;\n"+
+ "public class X { \n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"+
+ "record Point(@RCMU int myInt, char myChar) {\n"+
+ " @RCMU public int myInt(){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ "}\n"+
+ "@Target({ ElementType.RECORD_COMPONENT, ElementType.METHOD, ElementType.TYPE_USE})\n"+
+ "@interface RCMU {}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Method descriptor #25 ()I\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " public int myInt();\n" +
+ " 0 aload_0 [this]\n" +
+ " 1 getfield Point.myInt : int [17]\n" +
+ " 4 ireturn\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 8]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: Point\n" +
+ " RuntimeInvisibleAnnotations: \n" +
+ " #8 @RCMU(\n" +
+ " )\n" +
+ " RuntimeInvisibleTypeAnnotations: \n" +
+ " #8 @RCMU(\n" +
+ " target type = 0x14 METHOD_RETURN\n" +
+ " )\n" +
+ " \n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug563181_03() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.lang.annotation.*;\n"+
+ "public class X { \n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"+
+ "record Point(@TypeAnnot @SimpleAnnot int myInt, char myChar) {}\n"+
+ "@Target({ ElementType.RECORD_COMPONENT, ElementType.METHOD})\n"+
+ "@Retention(RetentionPolicy.RUNTIME)\n" +
+ "@interface SimpleAnnot {}\n" +
+ "@Target({ ElementType.RECORD_COMPONENT, ElementType.TYPE_USE})\n"+
+ "@Retention(RetentionPolicy.RUNTIME)\n" +
+ "@interface TypeAnnot {}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Method descriptor #25 ()I\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " public int myInt();\n" +
+ " 0 aload_0 [this]\n" +
+ " 1 getfield Point.myInt : int [17]\n" +
+ " 4 ireturn\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 5]\n" +
+ " RuntimeVisibleAnnotations: \n" +
+ " #27 @SimpleAnnot(\n" +
+ " )\n" +
+ " RuntimeVisibleTypeAnnotations: \n" +
+ " #8 @TypeAnnot(\n" +
+ " target type = 0x14 METHOD_RETURN\n" +
+ " )\n" +
+ " \n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug563181_04() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "import java.lang.annotation.*;\n"+
+ "public class X { \n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"+
+ "record Point(@TypeAnnot @SimpleAnnot int myInt, char myChar) {\n"+
+ " @TypeAnnot @SimpleAnnot public int myInt(){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ "}\n"+
+ "@Target({ ElementType.RECORD_COMPONENT, ElementType.METHOD})\n"+
+ "@Retention(RetentionPolicy.RUNTIME)\n" +
+ "@interface SimpleAnnot {}\n" +
+ "@Target({ ElementType.RECORD_COMPONENT, ElementType.TYPE_USE})\n"+
+ "@Retention(RetentionPolicy.RUNTIME)\n" +
+ "@interface TypeAnnot {}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Method descriptor #25 ()I\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " public int myInt();\n" +
+ " 0 aload_0 [this]\n" +
+ " 1 getfield Point.myInt : int [17]\n" +
+ " 4 ireturn\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 5] local: this index: 0 type: Point\n" +
+ " RuntimeVisibleAnnotations: \n" +
+ " #27 @SimpleAnnot(\n" +
+ " )\n" +
+ " RuntimeVisibleTypeAnnotations: \n" +
+ " #8 @TypeAnnot(\n" +
+ " target type = 0x14 METHOD_RETURN\n" +
+ " )\n" +
+ " \n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "Point.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565104_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X { \n"+
+ " public record R() {}\n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Stack: 1, Locals: 1\n" +
+ " public X$R();\n" +
+ " 0 aload_0 [this]\n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$R.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565104_002() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X { \n"+
+ " record R() {}\n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Stack: 1, Locals: 1\n" +
+ " X$R();\n" +
+ " 0 aload_0 [this]\n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$R.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565104_003() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X { \n"+
+ " protected record R() {}\n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Stack: 1, Locals: 1\n" +
+ " protected X$R();\n" +
+ " 0 aload_0 [this]\n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$R.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565104_004() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X { \n"+
+ " private record R() {}\n"+
+ " public static void main(String[] args){}\n"+
+ "}\n"
+ },
+ "");
+ String expectedOutput =
+ " // Stack: 1, Locals: 1\n" +
+ " private X$R();\n" +
+ " 0 aload_0 [this]\n";
+ RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$R.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug564146_001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X(int i) {\n"+
+ " public X() {\n"+
+ " this.i = 10;\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public X() {\n" +
+ " ^^^\n" +
+ "A non-canonical constructor must start with an explicit invocation to a constructor\n" +
+ "----------\n");
+ }
+ public void testBug564146_002() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X(int i) {\n"+
+ " public X() {\n"+
+ " super();\n"+
+ " this.i = 10;\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public X() {\n" +
+ " ^^^\n" +
+ "A non-canonical constructor must start with an explicit invocation to a constructor\n" +
+ "----------\n");
+ }
+ public void testBug564146_003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X(int i) {\n"+
+ " public X(int i) {\n"+
+ " this.i = 10;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ public void testBug564146_004() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X(int i) {\n"+
+ " public X() {\n"+
+ " this(10);\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(new X().i());\n"+
+ " }\n"+
+ "}"
+ },
+ "10");
+ }
+ public void testBug564146_005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
+ " public X(int i) {\n"+
+ " this(10);\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " this(10);\n" +
+ " ^^^^^^^^^\n" +
+ "Recursive constructor invocation X(int)\n" +
+ "----------\n");
+ }
+ public void testBug564146_006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n"+
" public X() {\n"+
+ " System.out.println(10);\n"+
" this(10);\n"+
" }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " this(10);\n" +
+ " ^^^^^^^^^\n" +
+ "The body of a canonical constructor must not contain an explicit constructor call\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " this(10);\n" +
+ " ^^^^^^^^^\n" +
+ "Constructor call must be the first statement in a constructor\n" +
+ "----------\n");
+ }
+ public void testBug564146_007() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X(int i) {\n"+
+ " public X() {\n"+
+ " this(10);\n"+
+ " }\n"+
+ " public X(int i, int k) {\n"+
+ " this();\n"+
+ " }\n"+
" public static void main(String[] args) {\n"+
- " System.out.println(new X().i());\n"+
+ " System.out.println(new X(2, 3).i());\n"+
" }\n"+
"}"
+ },
+ "10");
+ }
+
+public void testBug564672_001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "class record {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " class record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_002() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "interface record {}\n;" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " interface record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_004() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ " class record {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " class record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_007() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " interface record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_008() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_009() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface Y extends record {\n"+
+ "}\n" +
+ "interface record {}\n" +
+ "class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " interface record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_010() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface Y extends record {\n"+
+ "}\n" +
+ "class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_011() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " interface record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_012() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_013() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ " class record {}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " class record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_014() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_015() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " interface record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_016() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_017() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " interface record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_018() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_019() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static record a(int i, int j) {\n" +
+ " record r=new record(i,j);\n" +
+ " return r;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " record r=new record(i,j);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " record r=new record(i,j);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " return r;\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"return\", byte expected\n" +
+ "----------\n");
+}
+public void testBug564672_020() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " class record {};\n" +
+ " static record a(int i, int j) {\n" +
+ " record r=new record();\n" +
+ " return r;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " class record {};\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " record r=new record();\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " record r=new record();\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " return r;\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"return\", byte expected\n" +
+ "----------\n");
+}
+public void testBug564672_021() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " interface IPoint {\n" +
+ " }\n" +
+ " record Point(int x, int y) implements IPoint {}\n" +
+ " static IPoint a(int i, int j) {\n" +
+ " Point record=new Point(i,j);\n" +
+ " return record;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(a(5,10));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "Point[x=5, y=10]");
+}
+public void testBug564672_022() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " record R(int i){} \n" +
+ " interface IPoint {\n" +
+ " record a(int i) {\n" +
+ " System.out.println(0);\n" +
+ " return new R(i);\n" +
+ " }\n" +
+ " }\n" +
+ " record Point(int x, int y) implements IPoint {}\n" +
+ " static IPoint a(int i, int j) {\n" +
+ " Point record=new Point(i,j);\n" +
+ " record.a(1);\n" +
+ " return record;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " System.out.println(0);\n" +
+ " ^\n" +
+ "Syntax error on token \".\", @ expected after this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " System.out.println(0);\n" +
+ " return new R(i);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Syntax error on tokens, delete these tokens\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " return new R(i);\n" +
+ " ^\n" +
+ "Syntax error, insert \")\" to complete SingleMemberAnnotation\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " return new R(i);\n" +
+ " ^\n" +
+ "Syntax error, insert \"SimpleName\" to complete QualifiedName\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 6)\n" +
+ " return new R(i);\n" +
+ " ^\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 6)\n" +
+ " return new R(i);\n" +
+ " ^\n" +
+ "Syntax error, insert \")\" to complete MethodDeclaration\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 11)\n" +
+ " Point record=new Point(i,j);\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "The constructor X.Point(int, int) is undefined\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 12)\n" +
+ " record.a(1);\n" +
+ " ^\n" +
+ "The method a(int) is undefined for the type X.Point\n" +
+ "----------\n");
+}
+public void testBug564672_023() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " interface IPoint {\n" +
+ " }\n" +
+ " record Point(int x, int y) implements IPoint {}\n" +
+ " static IPoint a(int i, int j) throws record{\n" +
+ " Point record=new Point(i,j);\n" +
+ " return record;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " static IPoint a(int i, int j) throws record{\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_024() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X() throws record {} \n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " X() throws record {} \n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_025() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n" +
+ " int a() throws record; \n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int a() throws record; \n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_026() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.List;" +
+ "public class X {\n" +
+ " List<record> R = new List<record>();\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " List<record> R = new List<record>();\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " List<record> R = new List<record>();\n" +
+ " ^^^^\n" +
+ "Cannot instantiate the type List<record>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 2)\n" +
+ " List<record> R = new List<record>();\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_027() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I<S> {\n" +
+ " void print(S arg);\n" +
+ "}\n" +
+ "public class X implements I<record>{\n" +
+ " void print(record arg){\n" +
+ " System.out.println(arg);\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " public class X implements I<record>{\n" +
+ " ^\n" +
+ "The type X must implement the inherited abstract method I<record>.print(record)\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " public class X implements I<record>{\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " void print(record arg){\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_028() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Y<record> {\n" +
+ " void equal(record R) {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class Y<record> {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " void equal(record R) {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_029() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Y<record> {\n" +
+ " Y(record R) {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class Y<record> {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " Y(record R) {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_030() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static record i= 0;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " static record i= 0;\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_031() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " record i=0;\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " record i=0;\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_032() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int sum(record i, int param){\n" +
+ " return 1;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " static int sum(record i, int param){\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_033() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X(record i, int param){\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " X(record i, int param){\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_034() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int sum(record i, int num);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int sum(record i, int num);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_035() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Greetings {\n" +
+ " void greet(String head, String tail);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " Greetings g = (record, y) -> {\n" +
+ " System.out.println(record + y);\n" +
+ " };\n" +
+ " g.greet(\"Hello, \", \"World!\");\n" +
+ " }\n" +
+ "}\n",
},
- "10");
+ "Hello, World!"
+ );
}
-public void testBug564146_005() {
+public void testBug564672_036() {
this.runNegativeTest(
new String[] {
"X.java",
- "public record X() {\n"+
- " public X(int i) {\n"+
- " this(10);\n"+
- " }\n"+
- "}",
+ "class Y {\n" +
+ " int sum(record this, int i, int num) {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int sum(record this, int i, int num) {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_037() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static record i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " static record i;\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_038() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " for (record i = 0; i<10; i++) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
},
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
- " this(10);\n" +
- " ^^^^^^^^^\n" +
- "Recursive constructor invocation X(int)\n" +
+ " for (record i = 0; i<10; i++) {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n");
}
-public void testBug564146_006() {
+public void testBug564672_039() {
this.runNegativeTest(
new String[] {
"X.java",
- "public record X() {\n"+
- " public X() {\n"+
- " System.out.println(10);\n"+
- " this(10);\n"+
- " }\n"+
- "}",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int rec[] = {1,2,3,4,5,6,7,8,9};\n" +
+ " for (record i: rec) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
},
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
- " this(10);\n" +
- " ^^^^^^^^^\n" +
- "The body of a canonical constructor must not contain an explicit constructor call\n" +
+ " for (record i: rec) {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
"----------\n" +
"2. ERROR in X.java (at line 4)\n" +
- " this(10);\n" +
- " ^^^^^^^^^\n" +
- "Constructor call must be the first statement in a constructor\n" +
+ " for (record i: rec) {\n" +
+ " ^^^\n" +
+ "Type mismatch: cannot convert from element type int to record\n" +
"----------\n");
}
-public void testBug564146_007() {
- runConformTest(
+public void testBug564672_040() {
+ this.runNegativeTest(
new String[] {
"X.java",
- "public record X(int i) {\n"+
- " public X() {\n"+
- " this(10);\n"+
- " }\n"+
- " public X(int i, int k) {\n"+
- " this();\n"+
- " }\n"+
- " public static void main(String[] args) {\n"+
- " System.out.println(new X(2, 3).i());\n"+
- " }\n"+
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try (record i = 0){\n" +
+ " }\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " try (record i = 0){\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_041() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try{\n" +
+ " }\n" +
+ " catch (record e) {}\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " catch (record e) {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_042() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record Point(record x, int i) { }\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " record Point(record x, int i) { }\n" +
+ " ^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " record Point(record x, int i) { }\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_043() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Point {\n" +
+ " <T> Point(T i) {\n" +
+ " }\n" +
+ " Point (int i, int j) {\n" +
+ " <record> this(null);\n" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " <record> this(null);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " <record> this(null);\n" +
+ " ^^^^^^^^^^^\n" +
+ "The constructor Point(record) refers to the missing type record\n" +
+ "----------\n");
+}
+public void testBug564672_044() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Point {\n" +
+ " <T> Point(T i) {\n" +
+ " }\n" +
+ "}\n" +
+ "class PointEx extends Point {\n" +
+ " PointEx (int i, int j) {\n" +
+ " <record> super(null);\n" +
+ " }\n;" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " <record> super(null);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " <record> super(null);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "The constructor Point(record) refers to the missing type record\n" +
+ "----------\n");
+}
+public void testBug564672_045() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Y {\n" +
+ " void m1() {} \n" +
+ " void m2() {\n" +
+ " this.<record>m1();" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " this.<record>m1(); }\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 4)\n" +
+ " this.<record>m1(); }\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic method m1() of type Y; it should not be parameterized with arguments <record>\n" +
+ "----------\n");
+}
+public void testBug564672_046() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Y{\n" +
+ " void a() {\n" +
+ " System.out.println(\"1\");\n" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new <record>Y().a();\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " new <record>Y().a();\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 8)\n" +
+ " new <record>Y().a();\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic constructor Y() of type Y; it should not be parameterized with arguments <record>\n" +
+ "----------\n");
+}
+public void testBug564672_047() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface Y{}\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new <record>Y() {\n" +
+ " void a() {\n" +
+ " System.out.println(\"1\");\n" +
+ " }\n" +
+ " }.a();\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new <record>Y() {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 5)\n" +
+ " new <record>Y() {\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic constructor Object() of type Object; it should not be parameterized with arguments <record>\n" +
+ "----------\n");
+}
+public void testBug564672_048() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Y{}\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new <record>Y() {\n" +
+ " void a() {\n" +
+ " System.out.println(\"1\");\n" +
+ " }\n" +
+ " }.a();\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new <record>Y() {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 5)\n" +
+ " new <record>Y() {\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic constructor Y() of type Y; it should not be parameterized with arguments <record>\n" +
+ "----------\n");
+}
+public void testBug564672_049() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " record[] y= new record[3]; \n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " record[] y= new record[3]; \n" +
+ " ^^^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " record[] y= new record[3]; \n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_050() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String s=\"Hello\";\n" +
+ " record y= (record)s; \n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " record y= (record)s; \n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " record y= (record)s; \n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_051() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String s=\"Hello\";\n" +
+ " if (s instanceof record) { \n" +
+ " System.out.println(1);\n" +
+ " }\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " if (s instanceof record) { \n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+public void testBug564672_052() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " List<String> messages = Arrays.asList(\"hello\", \"java\", \"testers!\");\n" +
+ " messages.forEach(record::length);\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " messages.forEach(record::length);\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved\n" +
+ "----------\n");
+}
+public void testBug564672_053() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " List<String> messages = Arrays.asList(\"hello\", \"java\", \"testers!\");\n" +
+ " messages.stream().map(record::new).toArray(record[]::new);\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " messages.stream().map(record::new).toArray(record[]::new);\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " messages.stream().map(record::new).toArray(record[]::new);\n" +
+ " ^^^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n");
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_001() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X extends record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "class record {}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_002() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 1)\n" +
+ " class X extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X extends record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_003() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X implements record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"+
+ "interface record {}\n;"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_004() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements record {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 1)\n" +
+ " class X implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " class X implements record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_005() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ " class record {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_006() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_007() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_008() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_009() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Y extends record {\n"+
+ "}\n" +
+ "interface record {}\n" +
+ "class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_010() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface Y extends record {\n"+
+ "}\n" +
+ "class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 1)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_011() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_012() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_013() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Z {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ " class record {}\n" +
+ "}\n" +
+ "class X {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_014() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " class Y extends record {\n"+
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " class Y extends record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_015() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Z {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ "}\n" +
+ "class X {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_016() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " class Y implements record {\n"+
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " class Y implements record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_017() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Z {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ " interface record {}\n" +
+ "}\n" +
+ "class X {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_018() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X {\n"+
+ " interface Y extends record {\n"+
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " interface Y extends record {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_019() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static record a(int i, int j) {\n" +
+ " record r=new record(i,j);\n" +
+ " return r;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " static record a(int i, int j) {\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " static record a(int i, int j) {\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 3)\n" +
+ " record r=new record(i,j);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 3)\n" +
+ " record r=new record(i,j);\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. WARNING in X.java (at line 3)\n" +
+ " record r=new record(i,j);\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 3)\n" +
+ " record r=new record(i,j);\n" +
+ " ^^^^^^\n" +
+ "record cannot be resolved to a type\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_020() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " class record {}\n" +
+ "\n" +
+ " static record a(int i, int j) {\n" +
+ " record r = new X().new record();\n" +
+ " return r;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_021() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X() throws record {} \n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record extends Exception {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_022() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Y {\n" +
+ " int a() throws record;\n" +
+ "}\n" +
+ "\n" +
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record extends Exception {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
"}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_023() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " List<record> R = new ArrayList<record>();\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record{}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_024() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface I<S> {\n" +
+ " void print(S arg);\n" +
+ "}\n" +
+ "\n" +
+ "public class X implements I<record> {\n" +
+ " public void print(record arg) {\n" +
+ " System.out.println(arg);\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_025() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Y<record> {\n" +
+ " void equal(record R) {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_026() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Y<record> {\n" +
+ " Y(record R) {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_027() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static record i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_028() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " record i = new record(0);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {\n" +
+ " int i;\n" +
+ " record (int i) {\n" +
+ " this.i=i;\n" +
+ " }\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_029() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static int sum(record i, int param) {\n" +
+ " return 1;\n" +
+ " }\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record{}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_030() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X(record i, int param){\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record{}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_031() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int sum(record i, int num);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record{}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_032() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Greetings {\n" +
+ " void greet(String head, String tail);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " Greetings g = (record, y) -> {\n" +
+ " System.out.println(record + y);\n" +
+ " };\n" +
+ " g.greet(\"Hello, \", \"World!\");\n" +
+ " }\n" +
+ "}\n",
},
- "10");
+ "Hello, World!",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_033() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record {\n" +
+ " int sum(record this, int i, int num) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_034() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static Rec record;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class Rec {}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_035() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.Iterator;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int rec[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" +
+ " String s=\"\";\n" +
+ " List <record> recList= new ArrayList<>();\n" +
+ " for (int i:rec) {\n" +
+ " recList.add(new record(i));\n" +
+ " }\n" +
+ " for (Iterator<record> i =recList.iterator(); i.hasNext();) {\n" +
+ " s=s+i.next()+\" \";\n" +
+ " }\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record {\n" +
+ " int i;\n" +
+ " record (int i) {\n" +
+ " this.i=i;\n" +
+ " }\n" +
+ " public String toString (){\n" +
+ " return Integer.toString(i);\n" +
+ " }\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_036() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int rec[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" +
+ " String s=\"\";\n" +
+ " List <record> recList= new ArrayList<>();\n" +
+ " for (int i:rec) {\n" +
+ " recList.add(new record(i));\n" +
+ " }\n" +
+ " for (record i : recList) {\n" +
+ " s=s+i+\" \";\n" +
+ " }\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record {\n" +
+ " int i;\n" +
+ " record (int i) {\n" +
+ " this.i=i;\n" +
+ " }\n" +
+ " public String toString (){\n" +
+ " return Integer.toString(i);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_037() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try (record i = new record (0)){\n" +
+ " } catch (Exception e) {\n" +
+ " e.printStackTrace();\n" +
+ " }\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record implements AutoCloseable{\n" +
+ " int i;\n" +
+ " record (int i) {\n" +
+ " this.i=i;\n" +
+ " }\n" +
+ " @Override\n" +
+ " public void close() throws Exception {}\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_038() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " throw new record();\n" +
+ " } catch (record e) {\n" +
+ " System.out.println(\"0\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record extends Exception {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_039() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record Point(record x, int i) { }\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "----------\n" +
+ "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" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 7)\n" +
+ " class record {}\n" +
+ " ^^^^^^\n" +
+ "\'record\' is not a valid type name; it is a restricted identifier and not allowed as a type identifier in Java 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_040() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Point {\n" +
+ " <T> Point(T i) {\n" +
+ " }\n" +
+ " Point (int i, int j) {\n" +
+ " <record> this(null);\n" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_041() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Point {\n" +
+ " <T> Point(T i) {\n" +
+ " }\n" +
+ "}\n" +
+ "class PointEx extends Point {\n" +
+ " PointEx (int i, int j) {\n" +
+ " <record> super(null);\n" +
+ " }\n;" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_042() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Y {\n" +
+ " <T> void m1() {} \n" +
+ " void m2() {\n" +
+ " this.<record>m1();" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_043() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Y{\n" +
+ " <T> Y() {}\n" +
+ " void a() {\n" +
+ " System.out.println(\"1\");\n" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new <record>Y().a();\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "1",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_044() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "interface Y{\n" +
+ "}\n" +
+ "\n" +
+ "class Z implements Y {\n" +
+ " <T> Z() {\n" +
+ " \n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new <record>Z() {\n" +
+ " void a() {\n" +
+ " System.out.println(\"1\");\n" +
+ " }\n" +
+ " }.a();\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "1",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_045() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class Y{" +
+ " <T> Y() {\n" +
+ " }" +
+ "}\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new <record>Y() {\n" +
+ " void a() {\n" +
+ " System.out.println(\"1\");\n" +
+ " }\n" +
+ " }.a();\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}"
+ },
+ "1",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_046() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " record[] y= new record[3]; \n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}" +
+ "class record {}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_047() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " StrRec s = new StrRec(\"Hello\");\n" +
+ " record y = (record) s;\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "class record {\n" +
+ "}\n" +
+ "\n" +
+ "class StrRec extends record {\n" +
+ " String s;\n" +
+ "\n" +
+ " StrRec(String s) {\n" +
+ " this.s = s;\n" +
+ " }\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_048() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " StrRec s=new StrRec(\"Hello\");\n" +
+ " if (s instanceof record) { \n" +
+ " System.out.println(1);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "class record {}\n" +
+ "\n" +
+ "class StrRec extends record {\n" +
+ " String s;\n" +
+ "\n" +
+ " StrRec(String s) {\n" +
+ " this.s = s;\n" +
+ " }\n" +
+ "}"
+ },
+ "1",
+ options
+ );
}
-public void testBug565830_01() {
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public void testBug564672b_049() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " List<String> messages = Arrays.asList(\"hello\", \"java\", \"testers!\");\n" +
+ " \n" +
+ " messages.stream().map(record::new).toArray(record[]::new);;\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}\n" +
+ "class record {\n" +
+ " String s;\n" +
+ "\n" +
+ " record(String s) {\n" +
+ " this.s = s;\n" +
+ " }\n" +
+ "}"
+ },
+ "0",
+ options
+ );
+}
+public void testBug565388_001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public non-sealed record X() {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public non-sealed record X() {}\n" +
+ " ^\n" +
+ "Illegal modifier for the record X; only public, final and strictfp are permitted\n" +
+ "----------\n"
+ );
+}
+public void testBug565388_002() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed record X() {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed record X() {}\n" +
+ " ^\n" +
+ "Illegal modifier for the record X; only public, final and strictfp are permitted\n" +
+ "----------\n"
+ );
+}
+public void testBug565786_001() throws IOException, ClassFormatException {
runConformTest(
new String[] {
"X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}\n"+
+ "interface I {\n"+
+ " record R() {}\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ " // Method descriptor #6 ()V\n" +
+ " // Stack: 1, Locals: 1\n" +
+ " public I$R();\n";
+ verifyClassFile(expectedOutput, "I$R.class", ClassFileBytesDisassembler.SYSTEM);
+}
+// Test that without an explicit canonical constructor, we
+// report the warning on the record type.
+public void testBug563182_01() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " ^^^^\n" +
+ "Type safety: Potential heap pollution via varargs parameter args\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+//Test that in presence of an explicit canonical constructor that is NOT annotated with @SafeVarargs,
+// we don't report the warning on the record type but report on the explicit canonical constructor
+public void testBug563182_02() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " Point(T ... args) { // 2\n" +
+ " this.args = args;\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " Point(T ... args) { // 2\n" +
+ " ^^^^\n" +
+ "Type safety: Potential heap pollution via varargs parameter args\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+//Test that in presence of an explicit canonical constructor that IS annotated with @SafeVarargs,
+//we don't report the warning on neither the record type nor the explicit canonical constructor
+public void testBug563182_03() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " @SafeVarargs\n" +
+ " Point(T ... args) { // 2\n" +
+ " this.args = args;\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+//Test that in presence of a compact canonical constructor that is NOT annotated with @SafeVarargs,
+//we don't report the warning on the compact canonical constructor but report on the record type
+public void testBug563182_04() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " Point { // 2\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " ^^^^\n" +
+ "Type safety: Potential heap pollution via varargs parameter args\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+//Test that in presence of a compact canonical constructor that IS annotated with @SafeVarargs,
+//we don't report the warning on neither the record type nor the compact canonical constructor
+public void testBug563182_05() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " @SafeVarargs\n" +
+ " Point { // 2\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+//Test that in presence of a non-canonical constructor that is annotated with @SafeVarargs,
+//we don't report the warning on the non-canonical constructor but report on the record type
+public void testBug563182_06() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " @SafeVarargs\n" +
+ " Point (String s, T ... t) {\n" +
+ " this(t);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " ^^^^\n" +
+ "Type safety: Potential heap pollution via varargs parameter args\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+//Test that in presence of a non-canonical constructor that is NOT annotated with @SafeVarargs,
+//we don't report the warning on the non-canonical constructor but report on the record type
+public void testBug563182_07() {
+ Map<String, String> customOptions = getCompilerOptions();
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<T> {\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " Point (String s, T ... t) {\n" +
+ " this(t);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " record Point<T> (T ... args) { // 1\n" +
+ " ^^^^\n" +
+ "Type safety: Potential heap pollution via varargs parameter args\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 3)\n" +
+ " Point (String s, T ... t) {\n" +
+ " ^\n" +
+ "Type safety: Potential heap pollution via varargs parameter t\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ customOptions);
+}
+ public void testBug563186_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record Point(int myInt){\n"+
+ " @Override\n" +
+ " public int myInt(){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ public void testBug563186_02() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record Point(int myInt){\n"+
+ " public int myInt(){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ public void testBug563186_03() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record Point(int myInt){\n"+
+ " @Override\n" +
+ " public int myInt(int i){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " private record Point(int myInt){\n" +
+ " ^^^^^\n" +
+ "The type X.Point is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " public int myInt(int i){\n" +
+ " ^^^^^^^^^^^^\n" +
+ "The method myInt(int) of type X.Point must override or implement a supertype method\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ getCompilerOptions());
+ }
+ public void testBug563186_04() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " private record Point(int myInt){\n"+
+ " public int myInt(int i){\n"+
+ " return this.myInt;\n" +
+ " }\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ public void testBug565732_01() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X {\n" +
+ "} "
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public record X {\n" +
+ " ^\n" +
+ "Syntax error, insert \"RecordHeader\" to complete RecordHeaderPart\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ getCompilerOptions());
+ }
+ public void testBug565732_02() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public record X<T> {\n" +
+ "} "
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public record X<T> {\n" +
+ " ^\n" +
+ "Syntax error, insert \"RecordHeader\" to complete RecordHeaderPart\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ getCompilerOptions());
+ }
+ // Test that a record without any record components was indeed compiled
+ // to be a record at runtime
+ public void testBug565732_03() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X() {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.class.getSuperclass().getName());\n" +
+ " }\n" +
+ "}"
+ },
+ "java.lang.Record");
+ }
+ // Test that a record without any record components was indeed compiled
+ // to be a record at runtime
+ public void testBug565732_04() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X<T>() {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.class.getSuperclass().getName());\n" +
+ " }\n" +
+ "}"
+ },
+ "java.lang.Record");
+ }
+ // Test that a "record" can be used as a method name and invoked inside a record
+ public void testBug565732_05() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X<T>() {\n" +
+ " public static void main(String[] args) {\n" +
+ " record();\n" +
+ " }\n" +
+ " public static void record() {\n" +
+ " System.out.println(\"record()\");\n" +
+ " }\n" +
+ "}"
+ },
+ "record()");
+ }
+ // Test that a "record" can be used as a label and invoked inside a record
+ public void testBug565732_06() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X<T>() {\n" +
+ " public static void main(String[] args) {\n" +
+ " boolean flag = true;\n" +
+ " record: {\n" +
+ " if (flag) {\n" +
+ " System.out.println(\"record:\");\n" +
+ " flag = false;\n" +
+ " break record;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}"
+ },
+ "record:");
+ }
+ public void testBug565732_07() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " record R {};\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " record R {};\n" +
+ " ^\n" +
+ "Syntax error, insert \"RecordHeader\" to complete RecordHeaderPart\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"--enable-preview"},
+ getCompilerOptions());
+ }
+ public void testBug565732_08() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(R.class.getSuperclass().getName());\n" +
+ " }\n" +
+ " record R() {};\n" +
+ "}"
+ },
+ "java.lang.Record");
+ }
+ public void testBug565830_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
"class X {\n"+
" void bar() throws Exception {\n"+
" record Bar(int x) implements java.io.Serializable {\n"+
@@ -3921,6 +7616,151 @@ public void testBug565830_01() {
"}",
},
"private final int X$1Bar.x");
+ }
+public void testBug566063_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void bar() throws Exception {\n"+
+ " enum E {\n"+
+ " ONE,\n"+
+ " TWO\n"+
+ " }\n"+
+ " 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"+
+ "}"
+ },
+ "ONE");
+}
+public void testBug566063_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void bar() throws Exception {\n"+
+ " static enum E {\n"+
+ " ONE,\n"+
+ " TWO\n"+
+ " }\n"+
+ " 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 3)\n" +
+ " static enum E {\n" +
+ " ^\n" +
+ "A local interface, enum or record E is implicitly static; cannot have explicit static declaration\n" +
+ "----------\n");
+}
+public void testBug566063_003() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void bar() throws Exception {\n"+
+ " static enum E {\n"+
+ " ONE,\n"+
+ " TWO\n"+
+ " }\n"+
+ " interface I {}\n"+
+ " static 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 3)\n" +
+ " static enum E {\n" +
+ " ^\n" +
+ "A local interface, enum or record E is implicitly static; cannot have explicit static declaration\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " static record Bar(E x) implements I{}\n" +
+ " ^^^\n" +
+ "A local interface, enum or record Bar is implicitly static; cannot have explicit static declaration\n" +
+ "----------\n");
+}
+public void testBug566063_004() {
+ 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");
+}
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public void testBug566418_001() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static void foo() {\n"+
+ " record R() {\n"+
+ " static int create(int lo) {\n"+
+ " return lo;\n"+
+ " }\n"+
+ " }\n"+
+ " System.out.println(R.create(0));\n"+
+ " }\n"+
+ " Zork();\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Zork();\n" +
+ " ^^^^^^\n" +
+ "Return type for the method is missing\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Zork();\n" +
+ " ^^^^^^\n" +
+ "This method requires a body instead of a semicolon\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
}
public void testBug565787_01() {
runConformTest(
@@ -3939,4 +7779,103 @@ public void testBug565787_01() {
},
"");
}
+public void testBug566554_01() {
+ runConformTest(
+ new String[] {
+ "Main.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class Main {\n" +
+ " public static void main(String[] args) {\n" +
+ " final Margin margins = new Margin(0);\n" +
+ " System.out.println(margins.left()); \n" +
+ " }\n" +
+ "}\n" +
+ "record Margin(int left) {\n" +
+ " public Margin left(int value) {\n" +
+ " return new Margin(value);\n" +
+ " }\n" +
+ " public String toString() {\n" +
+ " return \"Margin[left=\" + this.left + \"]\";\n" +
+ " }\n" +
+ "}",
+ },
+ "0");
+}
+public void testBug566554_02() {
+ runConformTest(
+ new String[] {
+ "Main.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class Main {\n" +
+ " public static void main(String[] args) {\n" +
+ " final Margin margins = new Margin(0);\n" +
+ " System.out.println(margins.left()); \n" +
+ " }\n" +
+ "}\n" +
+ "record Margin(int left) {\n" +
+ " public Margin left(int value) {\n" +
+ " return new Margin(value);\n" +
+ " }\n" +
+ " public int left() {\n" +
+ " return this.left;\n" +
+ " }\n" +
+ " public String toString() {\n" +
+ " return \"Margin[left=\" + this.left + \"]\";\n" +
+ " }\n" +
+ "}",
+ },
+ "0");
+}
+public void testBug566554_03() {
+ runConformTest(
+ new String[] {
+ "Main.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class Main {\n" +
+ " public static void main(String[] args) {\n" +
+ " final Margin margins = new Margin(0);\n" +
+ " System.out.println(margins.left(0)); \n" +
+ " }\n" +
+ "}\n" +
+ "record Margin(int left) {\n" +
+ " public Margin left(int value) {\n" +
+ " return new Margin(value);\n" +
+ " }\n" +
+ " public int left() {\n" +
+ " return this.left;\n" +
+ " }\n" +
+ " public String toString() {\n" +
+ " return \"Margin[left=\" + this.left + \"]\";\n" +
+ " }\n" +
+ "}",
+ },
+ "Margin[left=0]");
+}
+public void testBug566554_04() {
+ runNegativeTest(
+ new String[] {
+ "Main.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class Main {\n" +
+ " public static void main(String[] args) {\n" +
+ " final Margin margins = new Margin(0);\n" +
+ " int l = margins.left(0); \n" +
+ " }\n" +
+ "}\n" +
+ "record Margin(int left) {\n" +
+ " public Margin left(int value) {\n" +
+ " return new Margin(value);\n" +
+ " }\n" +
+ " public int left() {\n" +
+ " return this.left;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in Main.java (at line 5)\n" +
+ " int l = margins.left(0); \n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Margin to int\n" +
+ "----------\n");
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
index 71a25a3f03..52618d10e0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2019 GK Software SE and others.
+ * Copyright (c) 2011, 2020 GK Software SE and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -5617,7 +5617,7 @@ public void testBug542707_001() {
options);
}
public void testBug542707_002() {
- if (this.complianceLevel < ClassFileConstants.JDK14) return; // uses switch expression
+ if (this.complianceLevel < ClassFileConstants.JDK15) return; // uses switch expression
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR);
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
new file mode 100644
index 0000000000..809d744db6
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java
@@ -0,0 +1,5308 @@
+/*******************************************************************************
+ * Copyright (c) 2020 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
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
+import org.eclipse.jdt.core.util.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+public class SealedTypes15Tests extends AbstractRegressionTest9 {
+
+ static {
+// TESTS_NUMBERS = new int [] { 40 };
+// TESTS_RANGE = new int[] { 1, -1 };
+// TESTS_NAMES = new String[] { "testBug565847_001"};
+ }
+
+ public static Class<?> testClass() {
+ return SealedTypes15Tests.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
+ }
+ public SealedTypes15Tests(String testName){
+ super(testName);
+ }
+
+ // Enables the tests to run individually
+ protected Map<String, String> getCompilerOptions() {
+ Map<String, String> defaultOptions = super.getCompilerOptions();
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15); // FIXME
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ defaultOptions.put(CompilerOptions.OPTION_Store_Annotations, CompilerOptions.ENABLED);
+ return defaultOptions;
+ }
+
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput) {
+ runConformTest(testFiles, expectedOutput, getCompilerOptions());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map customOptions) {
+ Runner runner = new Runner();
+ runner.testFiles = testFiles;
+ runner.expectedOutputString = expectedOutput;
+ runner.vmArguments = new String[] {"--enable-preview"};
+ runner.customOptions = customOptions;
+ runner.javacTestOptions = JavacTestOptions.forReleaseWithPreview("15");
+ runner.runConformTest();
+ }
+ @Override
+ protected void runNegativeTest(String[] testFiles, String expectedCompilerLog) {
+ runNegativeTest(testFiles, expectedCompilerLog, JavacTestOptions.forReleaseWithPreview("15"));
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog) {
+ runWarningTest(testFiles, expectedCompilerLog, null);
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog, Map<String, String> customOptions) {
+ runWarningTest(testFiles, expectedCompilerLog, customOptions, null);
+ }
+ protected void runWarningTest(String[] testFiles, String expectedCompilerLog,
+ Map<String, String> customOptions, String javacAdditionalTestOptions) {
+
+ 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.runWarningTest();
+ }
+
+ private static void verifyClassFile(String expectedOutput, String classFileName, int mode)
+ throws IOException, ClassFormatException {
+ File f = new File(OUTPUT_DIR + File.separator + classFileName);
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", mode);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ System.out.println("...");
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ }
+
+ public void testBug563430_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed class Y permits X{}\n" +
+ "non-sealed class X extends Y {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n",
+ },
+ "0");
+ }
+ public void testBug563430_001a() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "non-sealed class X extends Y {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n",
+ "Y.java",
+ "sealed class Y permits X{}\n",
+ },
+ "0");
+ }
+ public void testBug563430_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I extends SI{}\n"+
+ "non-sealed class X implements SI{\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "sealed interface SI permits X, I{}\n" +
+ "non-sealed interface I2 extends I{}\n"
+ },
+ "0");
+ }
+ public void testBug562715_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed class X permits Y {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n" +
+ "non-sealed class Y extends X {\n"+
+ "}\n"
+ },
+ "100");
+ }
+ public void testBug562715_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public sealed class X {\n"+
+ " public static void main(String[] args){\n"+
+ " int sealed = 100;\n" +
+ " System.out.println(sealed);\n" +
+ " }\n"+
+ "}\n" +
+ "non-sealed class Y extends X {\n"+
+ "}\n"
+ },
+ "100");
+ }
+ public void testBug562715_003() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed public class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n" +
+ "non-sealed class Y extends X {\n"+
+ "}\n"
+ },
+ "100");
+ }
+ public void testBug562715_004() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I {}\n"+
+ "sealed public class X<T> {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n" +
+ "non-sealed class Y<T> extends X<T> {\n"+
+ "}\n" +
+ "non-sealed interface I2 extends I {}\n"
+ },
+ "100");
+ }
+ public void testBug562715_004a() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed public class X<T> {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n" +
+ "non-sealed class Y extends X {\n"+
+ "}\n"
+ },
+ "100");
+ }
+ public void testBug562715_005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "sealed public sealed class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " sealed public sealed class X {\n" +
+ " ^\n" +
+ "Duplicate modifier for the type X\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " sealed public sealed class X {\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares X as its direct superclass\n" +
+ "----------\n");
+ }
+ public void testBug562715_006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X {\n"+
+ " public static sealed void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed class X {\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares X as its direct superclass\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " public static sealed void main(String[] args){\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"sealed\", static expected\n" +
+ "----------\n");
+ }
+ public void testBug562715_007() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed @MyAnnot public class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n" +
+ "@interface MyAnnot {}\n" +
+ "non-sealed class Y extends X{}"
+ },
+ "100");
+ }
+ public void testBug562715_008() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed class X permits Y {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n"+
+ "sealed class Y extends X {}\n" +
+ "final class Z extends Y {}\n"
+ },
+ "100");
+ }
+ public void testBug562715_009() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed class X permits Y,Z {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n"+
+ "sealed class Y extends X {}\n" +
+ "final class Z extends X {}\n" +
+ "final class Y2 extends Y {}\n"
+ },
+ "100");
+ }
+ public void testBug562715_010() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits {\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares X as its direct superclass\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"permits\", { expected\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits {\n" +
+ " ^\n" +
+ "Syntax error, insert \"}\" to complete Block\n" +
+ "----------\n");
+ }
+ // TODO : Enable after error flag code implemented
+ public void _testBug562715_011() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "sealed enum Natural {ONE, TWO}\n"+
+ "public sealed class X {\n"+
+ " public static sealed void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " EXPECTED ERROR IN RECORD\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"sealed\", static expected\n" +
+ "----------\n");
+ }
+ public void _testBug562715_xxx() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "sealed record R() {}\n"+
+ "public sealed class X {\n"+
+ " public static sealed void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " EXPECTED ERROR IN RECORD\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"sealed\", static expected\n" +
+ "----------\n");
+ }
+ public void testBug563806_001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits Y, Z{\n"+
+ "}\n"+
+ "class Y {}\n"+
+ "class Z {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits Y, Z{\n" +
+ " ^\n" +
+ "Permitted class Y does not declare X as direct super class\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits Y, Z{\n" +
+ " ^\n" +
+ "Permitted class Z does not declare X as direct super class\n" +
+ "----------\n");
+ }
+ public void testBug563806_002() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits Y{\n"+
+ "}\n"+
+ "class Y {}\n"+
+ "class Z extends X{}",
+ "p1/A.java",
+ "package p1;\n"+
+ "public sealed class A extends X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed class X permits Y{\n" +
+ " ^\n" +
+ "Permitted class Y does not declare p1.X as direct super class\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 5)\n" +
+ " class Z extends X{}\n" +
+ " ^\n" +
+ "The class Z with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n" +
+ "3. ERROR in p1\\X.java (at line 5)\n" +
+ " class Z extends X{}\n" +
+ " ^\n" +
+ "The type Z extending a sealed class X should be a permitted subtype of X\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p1\\A.java (at line 2)\n" +
+ " public sealed class A extends X{}\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares A as its direct superclass\n" +
+ "----------\n" +
+ "2. ERROR in p1\\A.java (at line 2)\n" +
+ " public sealed class A extends X{}\n" +
+ " ^\n" +
+ "The type A extending a sealed class X should be a permitted subtype of X\n" +
+ "----------\n");
+ }
+ public void testBug563806_003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed interface X permits Y, Z{\n"+
+ "}\n"+
+ "class Y implements X{}\n"+
+ "class Z {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed interface X permits Y, Z{\n" +
+ " ^\n" +
+ "Permitted type Z does not declare X as direct super interface \n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " class Y implements X{}\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug563806_004() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, Z, Q{\n"+
+ "}\n"+
+ "class Y implements X{}\n" +
+ "interface Z {}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, Z, Q{\n" +
+ " ^\n" +
+ "Permitted type Z does not declare p1.X as direct super interface \n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, Z, Q{\n" +
+ " ^\n" +
+ "Q cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in p1\\X.java (at line 4)\n" +
+ " class Y implements X{}\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug563806_005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits Y, Y{\n"+
+ "}\n"+
+ "class Y extends X {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits Y, Y{\n" +
+ " ^\n" +
+ "Duplicate type Y for the type X in the permits clause\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " class Y extends X {}\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug563806_006() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits Y, p1.Y{\n"+
+ "}\n"+
+ "class Y extends X {}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed class X permits Y, p1.Y{\n" +
+ " ^^^^\n" +
+ "Duplicate type Y for the type X in the permits clause\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 4)\n" +
+ " class Y extends X {}\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug563806_007() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "}\n"+
+ "non-sealed class Y extends X {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " non-sealed class Y extends X {}\n" +
+ " ^\n" +
+ "A class Y declared as non-sealed should have either a sealed direct superclass or a sealed direct superinterface\n" +
+ "----------\n");
+ }
+ public void testBug563806_008() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y {\n"+
+ "}\n"+
+ "class Y implements X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "non-sealed public interface Y {}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 4)\n" +
+ " class Y implements X{}\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p2\\Y.java (at line 2)\n" +
+ " non-sealed public interface Y {}\n" +
+ " ^\n" +
+ "An interface Y declared as non-sealed should have a sealed direct superinterface\n" +
+ "----------\n");
+ }
+ public void testBug563806_009() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public sealed class X {\n"+
+ " public static void main(String[] args){\n"+
+ " System.out.println(100);\n" +
+ " }\n"+
+ "}\n"+
+ "final class Y extends X {}",
+ },
+ "100");
+ }
+ public void testBug563806_010() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits Y {\n"+
+ "}\n"+
+ "final class Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y extends p1.X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p2\\Y.java (at line 2)\n" +
+ " public final class Y extends p1.X{}\n" +
+ " ^^^^\n" +
+ "The type Y extending a sealed class X should be a permitted subtype of X\n" +
+ "----------\n");
+ }
+ public void testBug563806_011() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) { \n" +
+ " System.out.println(\"0\");\n" +
+ " }\n" +
+ "}\n" +
+ "sealed interface Y {\n"+
+ "}\n"+
+ "final class Z implements Y {}",
+ },
+ "0");
+ }
+ public void testBug563806_012() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y {\n"+
+ "}\n"+
+ "final class Y implements X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y implements p1.X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p2\\Y.java (at line 2)\n" +
+ " public final class Y implements p1.X{}\n" +
+ " ^^^^\n" +
+ "The type Y extending a sealed class X should be a permitted subtype of X\n" +
+ "----------\n");
+ }
+ public void testBug563806_013() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed interface X {\n"+
+ "}\n"+
+ "interface Y extends X {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " interface Y extends X {}\n" +
+ " ^\n" +
+ "The interface Y with a sealed direct superinterface X should be declared either sealed or non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug563806_014() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y {\n"+
+ "}\n"+
+ "interface Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public interface Y extends p1.X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 4)\n" +
+ " interface Y extends X{}\n" +
+ " ^\n" +
+ "The interface Y with a sealed direct superinterface X should be declared either sealed or non-sealed\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p2\\Y.java (at line 2)\n" +
+ " public interface Y extends p1.X{}\n" +
+ " ^\n" +
+ "The interface Y with a sealed direct superinterface X should be declared either sealed or non-sealed\n" +
+ "----------\n" +
+ "2. ERROR in p2\\Y.java (at line 2)\n" +
+ " public interface Y extends p1.X{}\n" +
+ " ^^^^\n" +
+ "The type Y extending a sealed interface X should be a permitted subtype of X\n" +
+ "----------\n");
+ }
+ public void testBug563806_015() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X permits Y{\n"+
+ "}\n"+
+ "final class Y extends X {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X permits Y{\n" +
+ " ^\n" +
+ "A type declaration X that has a permits clause should have a sealed modifier\n" +
+ "----------\n");
+ }
+ public void testBug563806_016() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public class X permits Y {\n"+
+ "}\n"+
+ "final class Y extends X{}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public class X permits Y {\n" +
+ " ^\n" +
+ "A type declaration X that has a permits clause should have a sealed modifier\n" +
+ "----------\n");
+ }
+ public void testBug563806_017() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public interface X permits Y{\n"+
+ "}\n"+
+ "final class Y implements X {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public interface X permits Y{\n" +
+ " ^\n" +
+ "A type declaration X that has a permits clause should have a sealed modifier\n" +
+ "----------\n");
+ }
+ public void testBug563806_018() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public interface X permits Y {\n"+
+ "}\n"+
+ "final class Y implements X{}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public interface X permits Y {\n" +
+ " ^\n" +
+ "A type declaration X that has a permits clause should have a sealed modifier\n" +
+ "----------\n");
+ }
+ public void testBug563806_019() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits Y, p2.Y {\n"+
+ "}\n"+
+ "final class Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y extends p1.X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed class X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y in an unnamed module should be declared in the same package p1 of declaring type X\n" +
+ "----------\n");
+ }
+ public void testBug563806_020() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, p2.Y {\n"+
+ "}\n"+
+ "final class Y implements X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y implements p1.X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y in an unnamed module should be declared in the same package p1 of declaring type X\n" +
+ "----------\n");
+ }
+ public void testBug563806_021() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, p2.Y {\n"+
+ "}\n"+
+ "non-sealed interface Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public non-sealed interface Y extends p1.X{}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y in an unnamed module should be declared in the same package p1 of declaring type X\n" +
+ "----------\n");
+ }
+ public void testBug563806_022() {
+ associateToModule("mod.one", "p1/X.java");
+ associateToModule("mod.two", "p2/Y.java");
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "mod.one/module-info.java",
+ "module mod.one {\n"+
+ "requires mod.two;\n"+
+ "}\n",
+ "mod.two/module-info.java",
+ "module mod.two {\n" +
+ "exports p2;\n"+
+ "}\n",
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits Y, p2.Y {\n"+
+ "}\n"+
+ "final class Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y {}",
+ };
+ runner.expectedCompilerLog =
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed class X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y in a named module mod.one should be declared in the same module mod.one of declaring type X\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed class X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted class Y does not declare p1.X as direct super class\n" +
+ "----------\n";
+ runner.runNegativeTest();
+ }
+ public void testBug563806_023() {
+ associateToModule("mod.one", "p1/X.java");
+ associateToModule("mod.two", "p2/Y.java");
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "mod.one/module-info.java",
+ "module mod.one {\n"+
+ "requires mod.two;\n"+
+ "}\n",
+ "mod.two/module-info.java",
+ "module mod.two {\n" +
+ "exports p2;\n"+
+ "}\n",
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, p2.Y {\n"+
+ "}\n"+
+ "final class Y implements X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y {}",
+ };
+ runner.expectedCompilerLog =
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y in a named module mod.one should be declared in the same module mod.one of declaring type X\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y does not declare p1.X as direct super interface \n" +
+ "----------\n";
+ runner.runNegativeTest();
+ }
+ public void testBug563806_024() {
+ associateToModule("mod.one", "p1/X.java");
+ associateToModule("mod.two", "p2/Y.java");
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "mod.one/module-info.java",
+ "module mod.one {\n"+
+ "requires mod.two;\n"+
+ "}\n",
+ "mod.two/module-info.java",
+ "module mod.two {\n" +
+ "exports p2;\n"+
+ "}\n",
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, p2.Y {\n"+
+ "}\n"+
+ "non-sealed interface Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public interface Y {}",
+ };
+ runner.expectedCompilerLog =
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y in a named module mod.one should be declared in the same module mod.one of declaring type X\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed interface X permits Y, p2.Y {\n" +
+ " ^^^^\n" +
+ "Permitted type Y does not declare p1.X as direct super interface \n" +
+ "----------\n";
+ runner.runNegativeTest();
+ }
+ public void testBug563806_025() {
+ associateToModule("mod.one", "p1/X.java");
+ associateToModule("mod.one", "p2/Y.java");
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "mod.one/module-info.java",
+ "module mod.one {\n"+
+ "}\n",
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits Y, p2.Y {\n"+
+ "}\n"+
+ "final class Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y extends p1.X{}",
+ };
+ runner.runConformTest();
+ }
+ public void testBug563806_026() {
+ associateToModule("mod.one", "p1/X.java", "p2/Y.java");
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "mod.one/module-info.java",
+ "module mod.one {\n"+
+ "}\n",
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, p2.Y {\n"+
+ "}\n"+
+ "final class Y implements X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public final class Y implements p1.X{}",
+ };
+ runner.runConformTest();
+ }
+ public void testBug563806_027() {
+ associateToModule("mod.one", "p1/X.java");
+ associateToModule("mod.one", "p2/Y.java");
+ Runner runner = new Runner();
+ runner.testFiles = new String[] {
+ "mod.one/module-info.java",
+ "module mod.one {\n"+
+ "}\n",
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed interface X permits Y, p2.Y {\n"+
+ "}\n"+
+ "non-sealed interface Y extends X{}\n",
+ "p2/Y.java",
+ "package p2;\n"+
+ "public non-sealed interface Y extends p1.X {}",
+ };
+ runner.runConformTest();
+ }
+ public void testBug563806_028() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public non-sealed enum X {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public non-sealed enum X {\n" +
+ " ^\n" +
+ "Illegal modifier for the enum X; only public is permitted\n" +
+ "----------\n");
+ }
+ public void testBug563806_029() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed enum X {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed enum X {\n" +
+ " ^\n" +
+ "Illegal modifier for the enum X; only public is permitted\n" +
+ "----------\n");
+ }
+ public void testBug563806_030() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public class X {\n"+
+ "static sealed enum Y {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 3)\n" +
+ " static sealed enum Y {}\n" +
+ " ^\n" +
+ "Illegal modifier for the member enum Y; only public, protected, private & static are permitted\n" +
+ "----------\n");
+ }
+ public void testBug563806_031() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public class X {\n"+
+ "static non-sealed enum Y {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 3)\n" +
+ " static non-sealed enum Y {}\n" +
+ " ^\n" +
+ "Illegal modifier for the member enum Y; only public, protected, private & static are permitted\n" +
+ "----------\n");
+ }
+ public void testBug563806_032() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed non-sealed interface X {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed non-sealed interface X {\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares X as its direct superclass\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed non-sealed interface X {\n" +
+ " ^\n" +
+ "An interface X is declared both sealed and non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug563806_033() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed @interface X {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public sealed @interface X {\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"sealed\", static expected\n" +
+ "----------\n");
+ }
+ public void testBug563806_034() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public non-sealed @interface X {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public non-sealed @interface X {\n" +
+ " ^\n" +
+ "An interface X declared as non-sealed should have a sealed direct superinterface\n" +
+ "----------\n");
+ }
+ public void testBug563806_035() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public non-sealed interface X {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " public non-sealed interface X {\n" +
+ " ^\n" +
+ "An interface X declared as non-sealed should have a sealed direct superinterface\n" +
+ "----------\n");
+ }
+ public void testBug563806_036() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public class X {\n"+
+ " public void foo() {\n"+
+ " sealed class Y{}\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 4)\n" +
+ " sealed class Y{}\n" +
+ " ^\n" +
+ "Illegal modifier for the local class Y; only abstract or final is permitted\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 4)\n" +
+ " sealed class Y{}\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares Y as its direct superclass\n" +
+ "----------\n");
+ }
+ public void testBug563806_037() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public class X {\n"+
+ " public void foo() {\n"+
+ " non-sealed class Y{}\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 4)\n" +
+ " non-sealed class Y{}\n" +
+ " ^\n" +
+ "Illegal modifier for the local class Y; only abstract or final is permitted\n" +
+ "----------\n");
+ }
+ public void testBug563806_038() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public class X {\n"+
+ " public void foo() {\n"+
+ " non-sealed sealed class Y{}\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 4)\n" +
+ " non-sealed sealed class Y{}\n" +
+ " ^\n" +
+ "Illegal modifier for the local class Y; only abstract or final is permitted\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 4)\n" +
+ " non-sealed sealed class Y{}\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares Y as its direct superclass\n" +
+ "----------\n");
+ }
+ public void testBug563806_039() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class A{}\n"+
+ "public class X {\n"+
+ " public void foo() {\n"+
+ " class Y extends A{}\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " sealed class A{}\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares A as its direct superclass\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 5)\n" +
+ " class Y extends A{}\n" +
+ " ^\n" +
+ "A local class Y cannot have a sealed direct superclass or a sealed direct superinterface A\n" +
+ "----------\n");
+ }
+ public void testBug564191_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X permits Y, Z{\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "final class Y extends X{}\n" +
+ "final class Z extends X{}\n",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #33 p1/Y,\n" +
+ " #35 p1/Z\n" +
+ "}";
+ verifyClassFile(expectedOutput, "p1/X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // Test that implicit permitted (top-level) types make it to the .class file
+ public void testBug564190_1() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "final class Y extends X{}\n" +
+ "final class Z extends X{}\n",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #33 p1/Y,\n" +
+ " #35 p1/Z\n" +
+ "}";
+ verifyClassFile(expectedOutput, "p1/X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // Test that implicit permitted final (member) types make it to the .class file
+ public void testBug564190_2() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ " final class Y extends X{}\n" +
+ " final class Z extends X{}\n" +
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #33 p1/X$Y,\n" +
+ " #35 p1/X$Z\n" +
+ "}";
+ verifyClassFile(expectedOutput, "p1/X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // Test that implicit permitted non-sealed (member) types make it to the .class file
+ public void testBug564190_3() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ " non-sealed class Y extends X{}\n" +
+ " non-sealed class Z extends X{}\n" +
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #33 p1/X$Y,\n" +
+ " #35 p1/X$Z\n" +
+ "}";
+ verifyClassFile(expectedOutput, "p1/X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // Test that implicit permitted member type is reported without final, sealed or non-sealed
+ public void testBug564190_4() throws IOException, ClassFormatException {
+ runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X {\n" +
+ " class Y extends X {}\n" +
+ " final class Z extends Y {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 3)\n" +
+ " class Y extends X {}\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n");
+ }
+ // Test that implicit permitted member type with implicit permitted types
+ // is reported when its permitted type doesn't extend the member type
+ public void testBug564190_5() throws IOException, ClassFormatException {
+ runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X {\n" +
+ " sealed class Y extends X {}\n" +
+ " final class Z {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 3)\n" +
+ " sealed class Y extends X {}\n" +
+ " ^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares Y as its direct superclass\n" +
+ "----------\n");
+ }
+ // Test that implicit permitted member type with explicit permits clause
+ // is reported when its permitted type doesn't extend the member type
+ public void testBug564190_6() throws IOException, ClassFormatException {
+ runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X {\n" +
+ " sealed class Y extends X permits Z {}\n" +
+ " final class Z {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 3)\n" +
+ " sealed class Y extends X permits Z {}\n" +
+ " ^\n" +
+ "Permitted class Z does not declare p1.X.Y as direct super class\n" +
+ "----------\n");
+ }
+ // Test that implicit permitted member type with explicit permits clause
+ // is reported when its permitted type doesn't extend the member type
+ public void testBug564190_7() throws IOException, ClassFormatException {
+ runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed interface SI {}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 2)\n" +
+ " sealed interface SI {}\n" +
+ " ^^\n" +
+ "Sealed class lacks the permits clause and no top level or nested class from the same compilation unit declares SI as its direct superclass\n" +
+ "----------\n");
+ }
+ public void testBug564450_001() throws IOException, ClassFormatException {
+ runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "sealed class X permits Y{\n" +
+ "}",
+ "p1/Y.java",
+ "package p1;\n"+
+ "class Y extends X {\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\Y.java (at line 2)\n" +
+ " class Y extends X {\n" +
+ " ^\n" +
+ "The class Y with a sealed direct superclass or a sealed direct superinterface X should be declared either final, sealed, or non-sealed\n" +
+ "----------\n");
+ }
+ public void testBug564047_001() throws CoreException, IOException {
+ String outputDirectory = Util.getOutputDirectory();
+ String lib1Path = outputDirectory + File.separator + "lib1.jar";
+ try {
+ Util.createJar(
+ new String[] {
+ "p/Y.java",
+ "package p;\n" +
+ "public sealed class Y permits Z{}",
+ "p/Z.java",
+ "package p;\n" +
+ "public final class Z extends Y{}",
+ },
+ lib1Path,
+ JavaCore.VERSION_15,
+ true);
+ String[] libs = getDefaultClassPaths();
+ int len = libs.length;
+ System.arraycopy(libs, 0, libs = new String[len+1], 0, len);
+ libs[len] = lib1Path;
+ this.runNegativeTest(
+ new String[] {
+ "src/p/X.java",
+ "package p;\n" +
+ "public class X extends Y {\n" +
+ " public static void main(String[] args){\n" +
+ " System.out.println(0);\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in src\\p\\X.java (at line 2)\n" +
+ " public class X extends Y {\n" +
+ " ^\n" +
+ "The class X with a sealed direct superclass or a sealed direct superinterface Y should be declared either final, sealed, or non-sealed\n" +
+ "----------\n" +
+ "2. ERROR in src\\p\\X.java (at line 2)\n" +
+ " public class X extends Y {\n" +
+ " ^\n" +
+ "The type X extending a sealed class Y should be a permitted subtype of Y\n" +
+ "----------\n",
+ libs,
+ true);
+ } catch (IOException e) {
+ System.err.println("could not write to current working directory ");
+ } finally {
+ new File(lib1Path).delete();
+ }
+
+ }
+ public void testBug564492_001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args){\n"+
+ " new Y(){};\n" +
+ " }\n"+
+ "}\n"+
+ "sealed class Y{}\n"+
+ "final class Z extends Y {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new Y(){};\n" +
+ " ^\n" +
+ "An anonymous class cannot subclass a sealed type Y\n" +
+ "----------\n");
+ }
+ public void testBug564492_002() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " IY y = new IY(){};\n"+
+ " }\n"+
+ "}\n"+
+ "sealed interface I {}\n"+
+ "sealed interface IY extends I {}\n"+
+ "final class Z implements IY{}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " IY y = new IY(){};\n" +
+ " ^^\n" +
+ "A local class new IY(){} cannot have a sealed direct superclass or a sealed direct superinterface IY\n" +
+ "----------\n");
+ }
+ public void testBug564492_003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits A.Y {\n"+
+ " public static void main(String[] args) {\n"+
+ " new A.Y() {};\n"+
+ " }\n"+
+ "}\n"+
+ " \n"+
+ "class A {\n"+
+ " static sealed class Y extends X permits Z {}\n"+
+ " final class Z extends Y{}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new A.Y() {};\n" +
+ " ^^^\n" +
+ "An anonymous class cannot subclass a sealed type A.Y\n" +
+ "----------\n");
+ }
+ public void testBug564492_004() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new A.IY() {};\n"+
+ " }\n"+
+ "}\n"+
+ " \n"+
+ "class A {\n"+
+ " sealed interface I permits IY{}\n"+
+ " sealed interface IY extends I permits Z {}\n"+
+ " final class Z implements IY{}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new A.IY() {};\n" +
+ " ^^^^\n" +
+ "A local class new IY(){} cannot have a sealed direct superclass or a sealed direct superinterface A.IY\n" +
+ "----------\n");
+ }
+ public void testBug564498_1() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits A.Y {\n" +
+ " public static void main(String[] args) {}\n" +
+ "}\n" +
+ "class A {\n" +
+ " sealed class Y extends X {\n" +
+ " final class SubInnerY extends Y {}\n" +
+ " } \n" +
+ " final class Z extends Y {}\n" +
+ "}",
+ },
+ "");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #24 p1/A$Y$SubInnerY,\n" +
+ " #26 p1/A$Z\n" +
+ "}";
+ verifyClassFile(expectedOutput, "p1/A$Y.class", ClassFileBytesDisassembler.SYSTEM);
+ expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #21 p1/A$Y\n";
+ verifyClassFile(expectedOutput, "p1/X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug564498_2() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits A.Y {\n" +
+ " public static void main(String[] args) {}\n" +
+ "}\n" +
+ "class A {\n" +
+ " sealed class Y extends X {} \n" +
+ " final class Z extends Y {}\n" +
+ " final class SubY extends Y {}" +
+ "}",
+ },
+ "");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #22 p1/A$Z,\n" +
+ " #24 p1/A$SubY\n" +
+ "}";
+ verifyClassFile(expectedOutput, "p1/A$Y.class", ClassFileBytesDisassembler.SYSTEM);
+ expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #21 p1/A$Y\n";
+ verifyClassFile(expectedOutput, "p1/X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug564498_3() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits A.Y {\n" +
+ " public static void main(String[] args) {}\n" +
+ "}\n" +
+ "class A {\n" +
+ " sealed class Y extends X {\n" +
+ " final class SubInnerY extends Y {}\n" +
+ " } \n" +
+ " final class Z extends Y {}\n" +
+ " final class SubY extends Y {}" +
+ "}",
+ },
+ "");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #24 p1/A$Y$SubInnerY,\n" +
+ " #26 p1/A$Z,\n" +
+ " #28 p1/A$SubY\n";
+ verifyClassFile(expectedOutput, "p1/A$Y.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug564498_4() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits A.Y {\n" +
+ " public static void main(String[] args) {}\n" +
+ "}\n" +
+ "class A {\n" +
+ " sealed class Y extends X permits Y.SubInnerY {\n" +
+ " final class SubInnerY extends Y {}\n" +
+ " } \n" +
+ "}",
+ },
+ "");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #24 p1/A$Y$SubInnerY\n";
+ verifyClassFile(expectedOutput, "p1/A$Y.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ // Reject references of membertype without qualifier of enclosing type in permits clause
+ public void testBug564498_5() throws IOException, ClassFormatException {
+ runNegativeTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "public sealed class X permits A.Y {\n" +
+ " public static void main(String[] args) {}\n" +
+ "}\n" +
+ "class A {\n" +
+ " sealed class Y extends X permits SubInnerY {\n" +
+ " final class SubInnerY extends Y {}\n" +
+ " } \n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\X.java (at line 6)\n" +
+ " sealed class Y extends X permits SubInnerY {\n" +
+ " ^^^^^^^^^\n" +
+ "SubInnerY cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in p1\\X.java (at line 7)\n" +
+ " final class SubInnerY extends Y {}\n" +
+ " ^\n" +
+ "The type SubInnerY extending a sealed class A.Y should be a permitted subtype of A.Y\n" +
+ "----------\n");
+ }
+ // accept references of membertype without qualifier of enclosing type in permits clause
+ // provided it is imported
+ public void testBug564498_6() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "p1/X.java",
+ "package p1;\n"+
+ "import p1.Y.Z;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {}\n" +
+ "}\n" +
+ "sealed class Y permits Z {\n" +
+ " final class Z extends Y {}\n" +
+ "}",
+ },
+ "");
+ }
+ public void testBug564613_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " public boolean permits( String s ) {\n"+
+ " return true;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " boolean b = new X().permits(\"hello\");\n"+
+ " System.out.println(b ? \"Hello\" : \"World\");\n"+
+ " }\n"+
+ "}",
+ },
+ "Hello");
+ }
+ public void testBug564613_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits permits Y, Z {}\n"+
+ "final class Y extends X{}\n" +
+ "final class Z extends X{}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public sealed class X permits permits Y, Z {}\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"permits\", delete this token\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_001() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class permits {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type permits\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class permits {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type permits\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_003() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " permits p;\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ "permits.java",
+ "public class permits {\n"+
+ "}",
+ },
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_004() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " permits p;\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ "permits.java",
+ "public class permits {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_005() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<permits> {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X<permits>\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_006() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<permits> {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X<permits>\n" +
+ "----------\n");
+ }
+ public void testBug564638_007() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends permits {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "class permits {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_008() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends permits {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "class permits {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_009() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements permits {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface permits {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_010() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements permits {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface permits {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_011() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X extends permits {\n"+
+ " default void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface permits {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_012() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X extends permits {\n"+
+ " default void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface permits {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_013() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends {\n"+
+ " permits foo() {\n" +
+ " Zork();\n" +
+ " return null;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X extends {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"extends\", Type expected after this token\n" +
+ "----------\n" +
+ "2. 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 15\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_014() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " permits foo() {\n" +
+ " Zork();\n" +
+ " return null;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_015() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() throws permits{\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_016() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() throws permits{\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_017() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X <T extends permits> {\n"+
+ " <T> void foo(T extends permits) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " class X <T extends permits> {\n" +
+ " ^\n" +
+ "Syntax error, insert \"}\" to complete ClassBody\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 2)\n" +
+ " <T> void foo(T extends permits) {\n" +
+ " ^\n" +
+ "The type parameter T is hiding the type T\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 2)\n" +
+ " <T> void foo(T extends permits) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"extends\", delete this token\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " }\n" +
+ " ^\n" +
+ "Syntax error on token \"}\", delete this token\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_018() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X <T extends permits>{\n"+
+ " <T> void foo(T extends permits) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "Syntax error, insert \"}\" to complete ClassBody\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 2)\n" +
+ " <T> void foo(T extends permits) {\n" +
+ " ^\n" +
+ "The type parameter T is hiding the type T\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 2)\n" +
+ " <T> void foo(T extends permits) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"extends\", delete this token\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 5)\n" +
+ " }\n" +
+ " ^\n" +
+ "Syntax error on token \"}\", delete this token\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_019() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " ONE(1);\n" +
+ " private final permits p;\n" +
+ " X(int p) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_020() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " ONE(1);\n" +
+ " private final permits p;\n" +
+ " X(int p) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_021() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " I i = (permits p)-> {};\n" +
+// " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " void apply(Object o);\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " I i = (permits p)-> {};\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "This lambda expression refers to the missing type permits\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_022() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " I i = (permits p)-> {};\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " void apply(Object o);\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " I i = (permits p)-> {};\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "This lambda expression refers to the missing type permits\n" +
+ "----------\n" +
+ "2. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_023() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(permits this) {}\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_024() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(permits this) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_025() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(permits this) {}\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_026() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(permits this) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_027() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class permits {\n"+
+ " public void foo(permits this) {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_028() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class permits {\n"+
+ " public void foo(permits this) {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_029() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " permits p;\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_030() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " permits p;\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_031() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " for (permits i = 0; i < 10; ++i) {} \n" +
+ " }\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_032() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " for (permits i = 0; i < 10; ++i) {} \n" +
+ " }\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_033() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(permits[] args) {\n" +
+ " for (permits p : args) {} \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. 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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_034() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(permits[] args) {\n" +
+ " for (permits p : args) {} \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ " 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_035() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (permits y = new Y()) {\n"+
+ " \n"+
+ " } catch (Exception e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_036() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (permits y = new Y()) {\n"+
+ " \n"+
+ " } catch (Exception e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_037() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (Y y = new Y()) {\n"+
+ " \n"+
+ " } catch (permits e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_038() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (Y y = new Y()) {\n"+
+ " \n"+
+ " } catch (permits e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_039() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X(permits p) {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " record X(permits p) {\n" +
+ " ^\n" +
+ "permits cannot be resolved to a type\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_040() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X(permits p) {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "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" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_041() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " <permits>this(t);\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " <permits>this(t);\n" +
+ " ^^^^^^^^\n" +
+ "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_042() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " <permits>this(t);\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_043() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " new <permits>X(t).foo();\n"+
+ " }\n"+
+ " public void foo() {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new <permits>X(t).foo();\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_044() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " new <permits>X(t).foo();\n"+
+ " }\n"+
+ " public void foo() {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new <permits>X(t).foo();\n" +
+ " ^^^^^^^^^^^^^^^^^\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" +
+ " 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_045() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new X();\n"+
+ " x.<permits>foo(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " x.<permits>foo(0);\n" +
+ " ^^^\n" +
+ "The parameterized method <permits>foo(permits) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_046() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new X();\n"+
+ " x.<permits>foo(0);\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The parameterized method <permits>foo(permits) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_047() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new permits();\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_048() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new permits();\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_049() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " new permits() {\n"+
+ " @Override\n"+
+ " void foo() {}\n"+
+ " }.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "abstract class permits {\n"+
+ " abstract void foo();\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_050() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " new permits() {\n"+
+ " @Override\n"+
+ " void foo() {\n"+
+ " Zork();\n"+
+ " }\n"+
+ " }.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "abstract class permits {\n"+
+ " abstract void foo();\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type new permits(){}\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638_051() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " Object[] p = new permits[10];\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_052() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " Object[] p = new permits[10];\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_053() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new X().foo((permits) null);\n"+
+ " }\n"+
+ " private void foo(permits o) {}\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new X().foo((permits) null);\n" +
+ " ^^^\n" +
+ "The method foo(permits) from the type X refers to the missing type permits\n" +
+ "----------\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 15\n" +
+ "----------\n" +
+ "3. 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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_054() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new X().foo((permits) null);\n"+
+ " }\n"+
+ " private void foo(permits o) {}\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new X().foo((permits) null);\n" +
+ " ^^^\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" +
+ " 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 15\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" +
+ " 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_055() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " private void foo(Object o) {\n"+
+ " if (o instanceof permits) {}\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_056() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " private void foo(Object o) {\n"+
+ " if (o instanceof permits) {}\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638_057() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " @SuppressWarnings(\"unused\")\n"+
+ " I i = permits :: new;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class permits{}\n" +
+ "interface I {\n"+
+ " Object gen();\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638_058() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " @SuppressWarnings(\"unused\")\n"+
+ " I i = permits :: new;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class permits{}\n" +
+ "interface I {\n"+
+ " Object gen();\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "2. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_001() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class sealed {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type sealed\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_002() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class sealed {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type sealed\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_003() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " sealed p;\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ "sealed.java",
+ "public class sealed {\n"+
+ "}",
+ },
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_004() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " sealed p;\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ "sealed.java",
+ "public class sealed {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_005() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<sealed> {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X<sealed>\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_006() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X<sealed> {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X<sealed>\n" +
+ "----------\n");
+ }
+ public void testBug564638b_007() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends sealed {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "class sealed {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_008() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends sealed {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "class sealed {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_009() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements sealed {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface sealed {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_010() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X implements sealed {\n"+
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface sealed {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_011() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X extends sealed {\n"+
+ " default void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface sealed {\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_012() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface X extends sealed {\n"+
+ " default void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface sealed {\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_013() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X extends {\n"+
+ " sealed foo() {\n" +
+ " Zork();\n" +
+ " return null;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " class X extends {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"extends\", Type expected after this token\n" +
+ "----------\n" +
+ "2. 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 15\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_014() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " sealed foo() {\n" +
+ " Zork();\n" +
+ " return null;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_015() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() throws sealed{\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_016() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() throws sealed{\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_017() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X <T extends sealed> {\n"+
+ " <T> void foo(T extends sealed) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " class X <T extends sealed> {\n" +
+ " ^\n" +
+ "Syntax error, insert \"}\" to complete ClassBody\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 2)\n" +
+ " <T> void foo(T extends sealed) {\n" +
+ " ^\n" +
+ "The type parameter T is hiding the type T\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 2)\n" +
+ " <T> void foo(T extends sealed) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"extends\", delete this token\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " }\n" +
+ " ^\n" +
+ "Syntax error on token \"}\", delete this token\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_018() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X <T extends sealed>{\n"+
+ " <T> void foo(T extends sealed) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "Syntax error, insert \"}\" to complete ClassBody\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 2)\n" +
+ " <T> void foo(T extends sealed) {\n" +
+ " ^\n" +
+ "The type parameter T is hiding the type T\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 2)\n" +
+ " <T> void foo(T extends sealed) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error on token \"extends\", delete this token\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 5)\n" +
+ " }\n" +
+ " ^\n" +
+ "Syntax error on token \"}\", delete this token\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_019() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " ONE(1);\n" +
+ " private final sealed p;\n" +
+ " X(int p) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_020() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "enum X {\n"+
+ " ONE(1);\n" +
+ " private final sealed p;\n" +
+ " X(int p) {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_021() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " I i = (sealed p)-> {};\n" +
+// " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " void apply(Object o);\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " I i = (sealed p)-> {};\n" +
+ " ^^^^^^^^^^^^\n" +
+ "This lambda expression refers to the missing type sealed\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_022() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " I i = (sealed p)-> {};\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " void apply(Object o);\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " I i = (sealed p)-> {};\n" +
+ " ^^^^^^^^^^^^\n" +
+ "This lambda expression refers to the missing type sealed\n" +
+ "----------\n" +
+ "2. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_023() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(sealed this) {}\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_024() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(sealed this) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_025() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(sealed this) {}\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_026() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public void foo(sealed this) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_027() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class sealed {\n"+
+ " public void foo(sealed this) {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_028() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " class sealed {\n"+
+ " public void foo(sealed this) {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_029() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " sealed p;\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_030() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " sealed p;\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_031() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " for (sealed i = 0; i < 10; ++i) {} \n" +
+ " }\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_032() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n" +
+ " for (sealed i = 0; i < 10; ++i) {} \n" +
+ " }\n" +
+ " void foo() {\n" +
+ " Zork();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_033() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(sealed[] args) {\n" +
+ " for (sealed p : args) {} \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. 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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_034() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(sealed[] args) {\n" +
+ " for (sealed p : args) {} \n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ " 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_035() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (sealed y = new Y()) {\n"+
+ " \n"+
+ " } catch (Exception e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_036() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (sealed y = new Y()) {\n"+
+ " \n"+
+ " } catch (Exception e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_037() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (Y y = new Y()) {\n"+
+ " \n"+
+ " } catch (sealed e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_038() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " try (Y y = new Y()) {\n"+
+ " \n"+
+ " } catch (sealed e) {\n"+
+ " e.printStackTrace();\n"+
+ " } finally {\n"+
+ " \n"+
+ " }\n"+
+ " }\n"+
+ "}\n"+
+ "class Y implements AutoCloseable {\n"+
+ " @Override\n"+
+ " public void close() throws Exception {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_039() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X(sealed p) {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " record X(sealed p) {\n" +
+ " ^\n" +
+ "sealed cannot be resolved to a type\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_040() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "record X(sealed p) {\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "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" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_041() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " <sealed>this(t);\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " <sealed>this(t);\n" +
+ " ^^^^^^^^\n" +
+ "The parameterized constructor <sealed>X(sealed) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_042() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " <sealed>this(t);\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The parameterized constructor <sealed>X(sealed) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_043() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " new <sealed>X(t).foo();\n"+
+ " }\n"+
+ " public void foo() {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new <sealed>X(t).foo();\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "The parameterized constructor <sealed>X(sealed) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_044() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> X(T t) {}\n"+
+ " \n"+
+ " public X(int t, char c) {\n"+
+ " new <sealed>X(t).foo();\n"+
+ " }\n"+
+ " public void foo() {}\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " new <sealed>X(t).foo();\n" +
+ " ^^^^^^^^^^^^^^^^\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" +
+ " 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_045() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new X();\n"+
+ " x.<sealed>foo(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " x.<sealed>foo(0);\n" +
+ " ^^^\n" +
+ "The parameterized method <sealed>foo(sealed) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_046() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new X();\n"+
+ " x.<sealed>foo(0);\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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" +
+ "The parameterized method <sealed>foo(sealed) of type X is not applicable for the arguments (Integer)\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_047() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new sealed();\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_048() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public <T> void foo(T t) {}\n"+
+ " \n"+
+ " public X() {\n"+
+ " X x = new sealed();\n"+
+ " }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_049() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " new sealed() {\n"+
+ " @Override\n"+
+ " void foo() {}\n"+
+ " }.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "abstract class sealed {\n"+
+ " abstract void foo();\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_050() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " new sealed() {\n"+
+ " @Override\n"+
+ " void foo() {\n"+
+ " Zork();\n"+
+ " }\n"+
+ " }.foo();\n"+
+ " }\n"+
+ "}\n"+
+ "abstract class sealed {\n"+
+ " abstract void foo();\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type new sealed(){}\n" +
+ "----------\n" +
+ "3. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug564638b_051() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " Object[] p = new sealed[10];\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_052() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public X() {\n"+
+ " Object[] p = new sealed[10];\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_053() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new X().foo((sealed) null);\n"+
+ " }\n"+
+ " private void foo(sealed o) {}\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new X().foo((sealed) null);\n" +
+ " ^^^\n" +
+ "The method foo(sealed) from the type X refers to the missing type sealed\n" +
+ "----------\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 15\n" +
+ "----------\n" +
+ "3. 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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_054() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new X().foo((sealed) null);\n"+
+ " }\n"+
+ " private void foo(sealed o) {}\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " new X().foo((sealed) null);\n" +
+ " ^^^\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" +
+ " 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 15\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" +
+ " 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_055() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " private void foo(Object o) {\n"+
+ " if (o instanceof sealed) {}\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_056() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " private void foo(Object o) {\n"+
+ " if (o instanceof sealed) {}\n"+
+ " }\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING 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 15\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,
+ options
+ );
+ }
+ public void testBug564638b_057() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " @SuppressWarnings(\"unused\")\n"+
+ " I i = sealed :: new;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class sealed{}\n" +
+ "interface I {\n"+
+ " Object gen();\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\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 15\n" +
+ "----------\n");
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testBug564638b_058() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " @SuppressWarnings(\"unused\")\n"+
+ " I i = sealed :: new;\n"+
+ " Zork();\n"+
+ " }\n"+
+ "}\n"+
+ "class sealed{}\n" +
+ "interface I {\n"+
+ " Object gen();\n"+
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " Zork();\n" +
+ " ^^^^\n" +
+ "The method Zork() is undefined for the type X\n" +
+ "----------\n" +
+ "2. WARNING 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 15\n" +
+ "----------\n",
+ null,
+ true,
+ options
+ );
+ }
+ public void testBug565561_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits Outer.Inner {\n" +
+ " public static void main(String[] args){\n"+
+ " System.out.println(0);\n" +
+ " }\n"+
+ "}\n" +
+ "class Outer{\n" +
+ " final class Inner extends X{}\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ " Inner classes:\n" +
+ " [inner class info: #33 Outer$Inner, outer class info: #36 Outer\n" +
+ " inner name: #38 Inner, accessflags: 16 final]\n" +
+ "\n" +
+ "PermittedSubclasses:\n" +
+ " #33 Outer$Inner\n" +
+ "}";
+ verifyClassFile(expectedOutput, "X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565116_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "permits/X.java",
+ "package permits;\n"+
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " X x = new permits.X();\n"+
+ " }\n"+
+ "}",
+ },
+ "");
+ }
+ public void testBug565638_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}\n"+
+ "final class Outer {\n"+
+ " final class Inner extends X{\n"+
+ " }\n"+
+ "}",
+ },
+ "0");
+ }
+ public void testBug565782_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I permits X {}\n"+
+ "enum X implements I {\n"+
+ " ONE {};\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #14 X$1\n" +
+ "}";
+ verifyClassFile(expectedOutput, "X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565782_002() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I permits X {}\n"+
+ "public enum X implements I {\n"+
+ " ONE ;\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput = "public final enum X implements I {\n";
+ verifyClassFile(expectedOutput, "X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565782_003() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I {}\n"+
+ "enum X implements I {\n"+
+ " ONE {};\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #14 X$1\n" +
+ "}";
+ verifyClassFile(expectedOutput, "X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565782_004() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I {}\n"+
+ "class X {\n"+
+ " enum E implements I {\n"+
+ " ONE {};\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #14 X$E$1\n" +
+ "}";
+ verifyClassFile(expectedOutput, "X$E.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565782_005() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "sealed interface I permits X {}\n"+
+ "enum X implements I {\n"+
+ " ONE {},\n"+
+ " TWO {},\n"+
+ " THREE {};\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(0);\n"+
+ " }\n"+
+ "}",
+ },
+ "0");
+ String expectedOutput =
+ "PermittedSubclasses:\n" +
+ " #16 X$1,\n" +
+ " #25 X$2,\n" +
+ " #31 X$3\n" +
+ "}";
+ verifyClassFile(expectedOutput, "X.class", ClassFileBytesDisassembler.SYSTEM);
+ }
+ public void testBug565847_001() {
+ Map<String, String> options =getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
+
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public sealed class X permits Y {" +
+ "Zork();\n" +
+ "}\n" +
+ "final class Y extends X{}\n" +
+ "sealed interface I{}\n" +
+ "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",
+ null,
+ true,
+ options
+ );
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index 844e913414..e76af6a7ff 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -193,10 +193,17 @@ public static Test suite() {
ArrayList since_14 = new ArrayList();
since_14.add(SwitchExpressionsYieldTest.class);
since_14.add(RecordsRestrictedClassTest.class);
- since_14.add(PatternMatching14Test.class);
+ since_14.add(PatternMatching15Test.class);
since_14.add(JavadocTestForRecord.class);
since_14.add(BatchCompilerTest_14.class);
+ // add 14 specific test here (check duplicates)
+ ArrayList since_15 = new ArrayList();
+ since_15.add(SealedTypes15Tests.class);
+ since_15.add(ClassFileReaderTest_15.class);
+ since_15.add(JavadocTest_15.class);
+ since_15.add(LocalStaticsTest_15.class);
+ since_15.add(Unicode13Test.class);
// Build final test suite
TestSuite all = new TestSuite(TestAll.class.getName());
all.addTest(new TestSuite(StandAloneASTParserTest.class));
@@ -339,6 +346,23 @@ public static Test suite() {
TestCase.resetForgottenFilters(tests_14);
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_14), tests_14));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_15) != 0) {
+ ArrayList tests_15 = (ArrayList)standardTests.clone();
+ tests_15.addAll(since_1_4);
+ tests_15.addAll(since_1_5);
+ tests_15.addAll(since_1_6);
+ tests_15.addAll(since_1_7);
+ tests_15.addAll(since_1_8);
+ tests_15.addAll(since_9);
+ tests_15.addAll(since_10);
+ tests_15.addAll(since_11);
+ tests_15.addAll(since_12);
+ tests_15.addAll(since_13);
+ tests_15.addAll(since_14);
+ tests_15.addAll(since_15);
+ TestCase.resetForgottenFilters(tests_15);
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_15), tests_15));
+ }
all.addTest(new TestSuite(Jsr14Test.class));
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
index f9400d4522..dfef5b3a81 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
@@ -33,14 +33,14 @@ public class TextBlockTest extends AbstractRegressionTest {
static {
// TESTS_NUMBERS = new int [] { 40 };
-// TESTS_NAMES = new String[] { "testCompliances_14" };
+// TESTS_NAMES = new String[] { "testCompliances_13" };
}
public static Class<?> testClass() {
return TextBlockTest.class;
}
public static Test suite() {
- return buildMinimalComplianceTestSuite(testClass(), F_14);
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
}
public TextBlockTest(String testName){
super(testName);
@@ -51,15 +51,17 @@ public class TextBlockTest extends AbstractRegressionTest {
// Enables the tests to run individually
protected Map<String, String> getCompilerOptions(boolean previewFlag) {
Map<String, String> defaultOptions = super.getCompilerOptions();
- defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14);
- defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
- defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
- defaultOptions.put(CompilerOptions.OPTION_EnablePreviews, previewFlag ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
+ defaultOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+ defaultOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
defaultOptions.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
return defaultOptions;
}
protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions, String[] vmArguments) {
- runConformTest(testFiles, expectedOutput, customOptions, vmArguments, new JavacTestOptions("-source 14 --enable-preview"));
+ runConformTest(testFiles, expectedOutput, customOptions, vmArguments, new JavacTestOptions("-source 15 "));
+ }
+ protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions) {
+ runConformTest(true, testFiles, null, expectedOutput, null, new JavacTestOptions("-source 15"));
}
protected void runConformTest(
// test directory preparation
@@ -211,8 +213,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - escaped '\'
@@ -231,8 +232,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"abc\\def",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* Positive - Multi line text block with varying indentation
@@ -257,8 +257,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" line 2\n" +
"\n" +
"line 3",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* Positive - Multi line text block with varying indentation
@@ -283,8 +282,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" line 2\n" +
"\n" +
"line 3", // the trailing whitespace is trimmed by the test framework
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* Positive - Multi line text block with varying indentation
@@ -312,8 +310,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"\n" +
" line 3\n" +
">", // the trailing whitespace is trimmed by the test framework
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using unescaped '"' in text block
@@ -332,8 +329,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"\"abc-def",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using escaped '"' in text block
@@ -351,8 +347,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"\"abc-def\"",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using escaped \ and escaped " in text block
@@ -370,8 +365,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"\"abc\"\"\"def",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using Unicode in text block
@@ -391,8 +385,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"true",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - bigger piece of code as text block
@@ -415,8 +408,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"public void print(Object o) {\n" +
" System.out.println(Objects.toString(o));\n" +
"}",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - concatenation of string with text block
@@ -439,8 +431,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"public void print(Object o) {\n" +
" System.out.println(Objects.toString(o));\n" +
"}",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - freely using quotes
@@ -470,8 +461,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"can make words mean so many different things.\"\n" +
"\"The question is,\" said Humpty Dumpty,\n" +
"\"which is to be master - that's all.",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - html code with indentation
@@ -497,8 +487,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - html code with indentation with empty lines
@@ -525,8 +514,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
" </html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - html code with indentation with \r as terminator
@@ -553,8 +541,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - html code with indentation and trailing whitespace
@@ -581,8 +568,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using octal escape char for trailing whitespace
@@ -608,8 +594,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p> \n" +
" </body> \n" +
"</html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using text block as a method argument
@@ -635,8 +620,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
" </html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - using variable assigned with text block as a method argument
@@ -663,8 +647,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
/*
* positive - assigning strings and text blocks interchangeably.
@@ -692,11 +675,11 @@ public class TextBlockTest extends AbstractRegressionTest {
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>",
- null,
- new String[] {"--enable-preview"});
+ null);
}
public void test024() {
runConformTest(
+ true,
new String[] {
"Main.java",
"@SuppressWarnings(\"preview\")\n" +
@@ -724,6 +707,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" }\n" +
"}"
},
+ null,
"public class XYZ {\n" +
" public static String textb = \"\"\"\n" +
" abc\\\"\"\"def\"\n" +
@@ -733,7 +717,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" }\n" +
"}",
null,
- new String[] {"--enable-preview"});
+ JavacTestOptions.DEFAULT);
}
public void test025() {
runNegativeTest(
@@ -798,8 +782,7 @@ public class TextBlockTest extends AbstractRegressionTest {
" bar(MyDay.SUNDAY);\n" +
" }\n" +
" }",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
// An empty text block
public void test028() {
@@ -816,8 +799,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
// An empty text block
public void test029() {
@@ -836,32 +818,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"Hello Guru", // output comparison tool strips off all trailing whitespace
- getCompilerOptions(),
- new String[] {"--enable-preview"});
- }
- public void testBug550356() {
- Map<String, String> options = getCompilerOptions(false);
- runNegativeTest(
- new String[] {
- "X.java",
- "public class X {\n" +
- " public static String textb = \"\"\"\n" +
- "\"\"\";\n" +
- " public static void main(String[] args) {\n" +
- " System.out.println(textb);\n" +
- " }\n" +
- "}\n"
- },
- "----------\n" +
- "1. ERROR in X.java (at line 2)\n" +
- " public static String textb = \"\"\"\n" +
- "\"\"\";\n" +
- " ^^^^^^^\n" +
- "Text Blocks is a preview feature and disabled by default. Use --enable-preview to enable\n" +
- "----------\n",
- null,
- true,
- options);
+ getCompilerOptions());
}
public void testBug551948_1() {
runConformTest(
@@ -880,8 +837,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", // output comparison tool strips off all trailing whitespace
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug551948_2() {
runConformTest(
@@ -899,8 +855,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"abc\n defghi",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug551948_3() {
runConformTest(
@@ -919,8 +874,7 @@ public class TextBlockTest extends AbstractRegressionTest {
},
"if x == True and \\\n" +
" y == False",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug551948_4() {
runConformTest(
@@ -939,8 +893,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"red green blue orange",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug551948_5() {
runNegativeTest(
@@ -983,8 +936,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"A line with spaces",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug551948_7() {
runConformTest(
@@ -1003,8 +955,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"red \ngreen \nblue", // trailing whitespaces are trimmed
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug551948_8() {
runConformTest(
@@ -1028,8 +979,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"aaa\n\n" +
"bbb\n\n\n" +
"ccc",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_1() {
runConformTest(
@@ -1051,8 +1001,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_2() {
runConformTest(
@@ -1075,8 +1024,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_3() {
runConformTest(
@@ -1099,8 +1047,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_4() {
runConformTest(
@@ -1129,8 +1076,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_5() {
runConformTest(
@@ -1153,8 +1099,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"false",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_6() {
runConformTest(
@@ -1176,8 +1121,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_7() {
runConformTest(
@@ -1199,8 +1143,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_8() {
runConformTest(
@@ -1216,8 +1159,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"26",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
// Escaped """ with escaping at the first '"'
public void testCompliances_9() {
@@ -1234,8 +1176,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"26",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
// Escaped """ with escaping at the second '"'
public void testCompliances_10() {
@@ -1252,8 +1193,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"26",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
// Escaped """ with escaping at the third '"'
public void testCompliances_11() {
@@ -1270,8 +1210,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"26",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_12() {
runConformTest(
@@ -1293,8 +1232,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_13() {
runConformTest(
@@ -1315,8 +1253,7 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"256",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testCompliances_14() {
runConformTest(
@@ -1340,17 +1277,45 @@ public class TextBlockTest extends AbstractRegressionTest {
"}"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
}
public void testBug553252() {
Map<String, String> defaultOptions = super.getCompilerOptions();
Map<String, String> copy = new HashMap<String, String>(defaultOptions);
- copy.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_13);
- copy.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_13);
- copy.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_13);
+ copy.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14);
+ copy.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
+ copy.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
+ copy.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(textb);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public static String textb = \"\"\"\n" +
+ "\"\"\";\n" +
+ " ^^^^^^^\n" +
+ "The Java feature \'Text Blocks\' is only available with source level 15 and above\n" +
+ "----------\n",
+ null,
+ true,
+ new String[] {"-source 14 "},
+ copy);
+ }
+ public void testBug553252b() {
+ Map<String, String> defaultOptions = super.getCompilerOptions();
+ Map<String, String> copy = new HashMap<String, String>(defaultOptions);
+ copy.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_14);
+ copy.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_14);
+ copy.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_14);
copy.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
- copy.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
runNegativeTest(
new String[] {
"X.java",
@@ -1366,10 +1331,11 @@ public class TextBlockTest extends AbstractRegressionTest {
"1. ERROR in X.java (at line 0)\n" +
" public class X {\n" +
" ^\n" +
- "Preview features enabled at an invalid source release level 13, preview can be enabled only at source level 14\n" +
+ "Preview features enabled at an invalid source release level 14, preview can be enabled only at source level 15\n" +
"----------\n",
null,
true,
+ new String[] {"-source 14 --enable-preview"},
copy);
}
public void testBug562460() {
@@ -1385,8 +1351,87 @@ public class TextBlockTest extends AbstractRegressionTest {
"}\n"
},
"true",
- getCompilerOptions(),
- new String[] {"--enable-preview"});
+ getCompilerOptions());
+ }
+ public void testCompliances_15() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ " \\baa\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " print(textb.toCharArray());\n" +
+ " }\n" +
+ " private static void print(char[] val) {\n" +
+ " for (char c : val) {\n" +
+ " System.out.print((int)c + \",\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "8,97,97,",
+ getCompilerOptions());
+ }
+ public void testCompliances_16() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ " \\baa\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " print(textb.toCharArray());\n" +
+ " }\n" +
+ " private static void print(char[] val) {\n" +
+ " for (char c : val) {\n" +
+ " System.out.print((int)c + \",\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "8,97,97,",
+ getCompilerOptions());
+ }
+ public void testCompliances_17() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\\t\\baa\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " print(textb.toCharArray());\n" +
+ " }\n" +
+ " private static void print(char[] val) {\n" +
+ " for (char c : val) {\n" +
+ " System.out.print((int)c + \",\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "9,8,97,97,",
+ getCompilerOptions());
+ }
+ public void testCompliances_18() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static String textb = \"\"\"\n" +
+ "\\013\\baa\"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " print(textb.toCharArray());\n" +
+ " }\n" +
+ " private static void print(char[] val) {\n" +
+ " for (char c : val) {\n" +
+ " System.out.print((int)c + \",\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "11,8,97,97,",
+ getCompilerOptions());
}
public void testBug565639_1() {
runConformTest(true,
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode13Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode13Test.java
new file mode 100644
index 0000000000..eb0a5b1f14
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Unicode13Test.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class Unicode13Test extends AbstractRegressionTest {
+public Unicode13Test(String name) {
+ super(name);
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_15);
+}
+public void test1() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int a\\u08BE; // new unicode character in unicode 13 \n" +
+ "}",
+ },
+ "",
+ options);
+}
+public void test2() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int a\\ud880\\udc00; // new unicode character in unicode 13 using high and low surrogate\n" +
+ "}",
+ },
+ "",
+ options);
+}
+public static Class<Unicode13Test> testClass() {
+ return Unicode13Test.class;
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java
index 52bce52859..64a71cf253 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/VarargsTest.java
@@ -39,7 +39,7 @@ public class VarargsTest extends AbstractComparableTest {
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test070b" };
+// TESTS_NAMES = new String[] { "test068" };
// TESTS_NUMBERS = new int[] { 61 };
// TESTS_RANGE = new int[] { 11, -1 };
}
@@ -2702,6 +2702,9 @@ public class VarargsTest extends AbstractComparableTest {
if (this.complianceLevel < ClassFileConstants.JDK1_7) return;
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.ERROR);
+
+ String[] bounds = new String[] { "Object","Serializable","Comparable<?>"};
+ String[] bounds15 = new String[] { "Object","Serializable","Comparable<?>", "Constable"};
this.runNegativeTest(
new String[] {
"X.java",
@@ -2730,7 +2733,7 @@ public class VarargsTest extends AbstractComparableTest {
"2. WARNING in X.java (at line 13)\n" +
" classes = X.asList2(String.class, Boolean.class);\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type safety: A generic array of Class<? extends "+intersection("Object","Serializable","Comparable<?>")+"> is created for a varargs parameter\n" +
+ "Type safety: A generic array of Class<? extends "+intersection(isJRE15Plus ? bounds15 : bounds)+"> is created for a varargs parameter\n" +
"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=337795 (test effect of SuppressWarnings (should suppress at declaration site, but not at call site)
@@ -2738,6 +2741,8 @@ public class VarargsTest extends AbstractComparableTest {
if (this.complianceLevel < ClassFileConstants.JDK1_7) return;
Map options = getCompilerOptions();
options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.ERROR);
+ String[] bounds = new String[] { "Object","Serializable","Comparable<?>"};
+ String[] bounds15 = new String[] { "Object","Serializable","Comparable<?>", "Constable"};
this.runNegativeTest(
new String[] {
"X.java",
@@ -2762,7 +2767,7 @@ public class VarargsTest extends AbstractComparableTest {
"1. WARNING in X.java (at line 14)\n" +
" classes = X.asList2(String.class, Boolean.class);\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Type safety: A generic array of Class<? extends "+intersection("Object","Serializable","Comparable<?>")+"> is created for a varargs parameter\n" +
+ "Type safety: A generic array of Class<? extends "+intersection(isJRE15Plus ? bounds15 : bounds)+ "> is created for a varargs parameter\n" +
"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=346042
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
index 0dee50504d..dbde1223af 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/dom/StandAloneASTParserTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2019 IBM Corporation and others.
+ * Copyright (c) 2010, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -65,7 +65,7 @@ public class StandAloneASTParserTest extends AbstractRegressionTest {
super(name);
}
- private static final int AST_JLS_LATEST = AST.JLS14;
+ private static final int AST_JLS_LATEST = AST.JLS15;
public ASTNode runConversion(
int astLevel,
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 25f31d6980..5da30c5524 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -46,6 +46,7 @@ public class AbstractCompilerTest extends TestCase {
public static final int F_12 = 0x200;
public static final int F_13 = 0x400;
public static final int F_14 = 0x800;
+ public static final int F_15 = 0x1000;
public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac"));
private static final int UNINITIALIZED = -1;
@@ -54,11 +55,14 @@ public class AbstractCompilerTest extends TestCase {
protected long complianceLevel;
protected boolean enableAPT = false;
+ protected boolean enablePreview = false;
protected static boolean isJRE9Plus = false; // Stop gap, so tests need not be run at 9, but some tests can be adjusted for JRE 9
+ protected static boolean isJRE10Plus = false;
protected static boolean isJRE11Plus = false;
protected static boolean isJRE12Plus = false;
protected static boolean isJRE13Plus = false;
protected static boolean isJRE14Plus = false;
+ protected static boolean isJRE15Plus = false;
protected static boolean reflectNestedClassUseDollar;
/**
@@ -112,6 +116,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_14) != 0) {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_14)));
}
+ if ((complianceLevels & AbstractCompilerTest.F_15) != 0) {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_15)));
+ }
}
/**
@@ -163,6 +170,9 @@ public class AbstractCompilerTest extends TestCase {
if ((complianceLevels & AbstractCompilerTest.F_14) != 0) {
suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_14)));
}
+ if ((complianceLevels & AbstractCompilerTest.F_15) != 0) {
+ suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_15)));
+ }
return suite;
}
@@ -327,6 +337,7 @@ public class AbstractCompilerTest extends TestCase {
}
}
checkCompliance(evaluationTestClass, minimalCompliance, suite, complianceLevels, AbstractCompilerTest.F_14, ClassFileConstants.MAJOR_VERSION_14, 14);
+ checkCompliance(evaluationTestClass, minimalCompliance, suite, complianceLevels, AbstractCompilerTest.F_15, ClassFileConstants.MAJOR_VERSION_15, 15);
return suite;
}
private static void checkCompliance(Class evaluationTestClass, int minimalCompliance, TestSuite suite,
@@ -396,6 +407,9 @@ public class AbstractCompilerTest extends TestCase {
*/
public static long highestComplianceLevels() {
int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((complianceLevels & AbstractCompilerTest.F_15) != 0) {
+ return ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_15);
+ }
if ((complianceLevels & AbstractCompilerTest.F_14) != 0) {
return ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_14);
}
@@ -458,12 +472,13 @@ public class AbstractCompilerTest extends TestCase {
public static int getPossibleComplianceLevels() {
if (possibleComplianceLevels == UNINITIALIZED) {
String specVersion = System.getProperty("java.specification.version");
- isJRE14Plus = CompilerOptions.VERSION_14.equals(specVersion);
+ isJRE15Plus = CompilerOptions.VERSION_15.equals(specVersion);
+ isJRE14Plus = isJRE15Plus || CompilerOptions.VERSION_14.equals(specVersion);
isJRE13Plus = isJRE14Plus || CompilerOptions.VERSION_13.equals(specVersion);
isJRE12Plus = isJRE13Plus || CompilerOptions.VERSION_12.equals(specVersion);
isJRE11Plus = isJRE12Plus || CompilerOptions.VERSION_11.equals(specVersion);
- isJRE9Plus = isJRE11Plus || CompilerOptions.VERSION_9.equals(specVersion)
- || CompilerOptions.VERSION_10.equals(specVersion);
+ isJRE10Plus = isJRE11Plus || CompilerOptions.VERSION_10.equals(specVersion);
+ isJRE9Plus = isJRE10Plus || CompilerOptions.VERSION_9.equals(specVersion);
initReflectionVersion();
String compliances = System.getProperty("compliance");
if (compliances != null) {
@@ -482,17 +497,26 @@ public class AbstractCompilerTest extends TestCase {
} else if (CompilerOptions.VERSION_1_8.equals(compliance)) {
possibleComplianceLevels |= F_1_8;
} else if (CompilerOptions.VERSION_9.equals(compliance)) {
- possibleComplianceLevels |= F_9;
+ if (isJRE9Plus)
+ possibleComplianceLevels |= F_9;
} else if (CompilerOptions.VERSION_10.equals(compliance)) {
- possibleComplianceLevels |= F_10;
+ if (isJRE10Plus)
+ possibleComplianceLevels |= F_10;
} else if (CompilerOptions.VERSION_11.equals(compliance)) {
- possibleComplianceLevels |= F_11;
+ if (isJRE11Plus)
+ possibleComplianceLevels |= F_11;
} else if (CompilerOptions.VERSION_12.equals(compliance)) {
- possibleComplianceLevels |= F_12;
+ if (isJRE12Plus)
+ possibleComplianceLevels |= F_12;
} else if (CompilerOptions.VERSION_13.equals(compliance)) {
- possibleComplianceLevels |= F_13;
+ if (isJRE13Plus)
+ possibleComplianceLevels |= F_13;
} else if (CompilerOptions.VERSION_14.equals(compliance)) {
- possibleComplianceLevels |= F_14;
+ if (isJRE14Plus)
+ possibleComplianceLevels |= F_14;
+ } else if (CompilerOptions.VERSION_15.equals(compliance)) {
+ if (isJRE15Plus)
+ possibleComplianceLevels |= F_15;
} else {
System.out.println("Ignoring invalid compliance (" + compliance + ")");
System.out.print("Use one of ");
@@ -508,7 +532,8 @@ public class AbstractCompilerTest extends TestCase {
System.out.print(CompilerOptions.VERSION_11 + ", ");
System.out.print(CompilerOptions.VERSION_12 + ", ");
System.out.print(CompilerOptions.VERSION_13 + ", ");
- System.out.println(CompilerOptions.VERSION_14);
+ System.out.println(CompilerOptions.VERSION_14 + ", ");
+ System.out.println(CompilerOptions.VERSION_15);
}
}
if (possibleComplianceLevels == 0) {
@@ -566,6 +591,10 @@ public class AbstractCompilerTest extends TestCase {
if (canRun14) {
possibleComplianceLevels |= F_14;
}
+ boolean canRun15 = canRun14 && !CompilerOptions.VERSION_14.equals(specVersion);
+ if (canRun15) {
+ possibleComplianceLevels |= F_15;
+ }
} else if ("1.0".equals(specVersion)
|| CompilerOptions.VERSION_1_1.equals(specVersion)
|| CompilerOptions.VERSION_1_2.equals(specVersion)
@@ -592,6 +621,9 @@ public class AbstractCompilerTest extends TestCase {
possibleComplianceLevels |= F_13;
if (!CompilerOptions.VERSION_13.equals(specVersion)) {
possibleComplianceLevels |= F_14;
+ if (!CompilerOptions.VERSION_14.equals(specVersion)) {
+ possibleComplianceLevels |= F_15;
+ }
}
}
}
@@ -769,7 +801,7 @@ public class AbstractCompilerTest extends TestCase {
}
protected static String getVersionString(long compliance) {
- String version = "version 14 : 58.0";
+ String version = "version 15 : 59.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";
@@ -778,7 +810,7 @@ public class AbstractCompilerTest extends TestCase {
int major = Integer.parseInt(ver) + ClassFileConstants.MAJOR_VERSION_0;
return "version " + ver + " : " + major + ".0";
}
- if (compliance >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_14)) return version; // keep this stmt for search for next bump up
+ if (compliance >= ClassFileConstants.getComplianceLevelForJavaVersion(ClassFileConstants.MAJOR_VERSION_15)) return version; // keep this stmt for search for next bump up
return version;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
index 39c6e45af4..69d0d40fca 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -458,6 +458,12 @@ public static void createJar(String[] pathsAndContents, String[] extraPathsAndCo
}
zip(classesDir, jarPath);
}
+public static void createJar(String[] javaPathsAndContents, String jarPath, String compliance, boolean preview) throws IOException {
+ Map options = getCompileOptions(compliance);
+ if (preview)
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ createJar(javaPathsAndContents, null, options, null, jarPath);
+}
public static void createJar(String[] javaPathsAndContents, String jarPath, String compliance) throws IOException {
createJar(javaPathsAndContents, null, jarPath, compliance);
}
diff --git a/org.eclipse.jdt.core.tests.compiler/test.xml b/org.eclipse.jdt.core.tests.compiler/test.xml
index afe7e7ccfb..b421dbdaf5 100644
--- a/org.eclipse.jdt.core.tests.compiler/test.xml
+++ b/org.eclipse.jdt.core.tests.compiler/test.xml
@@ -56,6 +56,7 @@
<property name="plugin-name" value="${plugin-name}"/>
<property name="classname"
value="org.eclipse.jdt.core.tests.compiler.regression.TestAll"/>
+ <property name="vmargs" value="-Dcompliance=1.4,1.7,1.8,15"/>
</ant>
<antcall target="evaluation_tests"/>

Back to the top