Bug 565622 - [16] JEP 394: Pattern Matching for instanceof (final)

Make the feature standard/final

Change-Id: I57c08febabc32b5941b594031e6da3e782fc14b7
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
similarity index 98%
rename from org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching15Test.java
rename to org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
index 7ff3cfd..ac57bc0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching15Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
@@ -22,7 +22,7 @@
 
 import junit.framework.Test;
 
-public class PatternMatching15Test extends AbstractRegressionTest {
+public class PatternMatching16Test extends AbstractRegressionTest {
 
 	private static final JavacTestOptions JAVAC_OPTIONS = new JavacTestOptions("-source 16 --enable-preview -Xlint:-preview");
 	static {
@@ -32,12 +32,12 @@
 	}
 
 	public static Class<?> testClass() {
-		return PatternMatching15Test.class;
+		return PatternMatching16Test.class;
 	}
 	public static Test suite() {
 		return buildMinimalComplianceTestSuite(testClass(), F_16);
 	}
-	public PatternMatching15Test(String testName){
+	public PatternMatching16Test(String testName){
 		super(testName);
 	}
 	// Enables the tests to run individually
@@ -75,9 +75,9 @@
 	}
 	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);
+		options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_15);
+		options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_15);
+		options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_15);
 		runNegativeTest(
 				new String[] {
 						"X1.java",
@@ -92,14 +92,14 @@
 				"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 "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +" and above\n" +
+				"The Java feature 'Pattern Matching in instanceof Expressions' is only available with source level "+ AbstractRegressionTest.PREVIEW_ALLOWED_LEVEL +" 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);
+		options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_16);
+		options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_16);
+		options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_16);
 	}
 	public void test000b() {
 		Map<String, String> options = getCompilerOptions(true);
@@ -125,13 +125,14 @@
 				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);
+		options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_16);
+		options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_16);
+		options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_16);
 	}
+	// No longer negative since pattern matching is a standard feature now.
 	public void test001() {
 		Map<String, String> options = getCompilerOptions(false);
-		runNegativeTest(
+		runConformTest(
 				new String[] {
 						"X1.java",
 						"public class X1 {\n" +
@@ -139,17 +140,11 @@
 						"		if (obj instanceof String s) {\n" +
 						"		}\n " +
 						"	}\n" +
+						"  public static void main(String[] obj) {\n" +
+						"	}\n" +
 						"}\n",
 				},
-				"----------\n" +
-				"1. ERROR in X1.java (at line 3)\n" +
-				"	if (obj instanceof String s) {\n" +
-				"	                   ^^^^^^^^\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,
-				true,
+				"",
 				options);
 	}
 	public void test002() {
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 e76af6a..ab165d8 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,7 +193,7 @@
 	 ArrayList since_14 = new ArrayList();
 	 since_14.add(SwitchExpressionsYieldTest.class);
 	 since_14.add(RecordsRestrictedClassTest.class);
-	 since_14.add(PatternMatching15Test.class);
+	 since_14.add(PatternMatching16Test.class);
 	 since_14.add(JavadocTestForRecord.class);
 	 since_14.add(BatchCompilerTest_14.class);
 
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 2ebcd75..ced4bcf 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
@@ -213,7 +213,7 @@
 		int lev = complianceLevels & abstractCompilerTestCompliance;
 		if (lev != 0) {
 			if (lev < minimalCompliance) {
-				System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance" + release + "!");
+				System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance " + release + "!");
 			} else {
 				suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.getComplianceLevelForJavaVersion(classFileConstantsVersion)));
 			}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
index ac23561..8df9610 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
@@ -45,7 +45,7 @@
 	PATTERN_MATCHING_IN_INSTANCEOF(ClassFileConstants.JDK16,
 			Messages.bind(Messages.pattern_matching_instanceof),
 			new char[][] {},
-			true),
+			false),
 
 	RECORDS(ClassFileConstants.JDK16,
 			Messages.bind(Messages.records),