update jdt.core to I20201028-1800 for 2020-12 M2
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java
index eac50c6..db7121e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/PatternMatchingSelectionTest.java
@@ -133,4 +133,34 @@
 	checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
 			selectionIdentifier, expectedReplacedSource, testName);
 }
+public void test004() throws JavaModelException {
+	String string =  "public class X {\n"
+			+ "    @SuppressWarnings(\"preview\")\n"
+			+ "	   public void f(Object obj, boolean b) {\n"
+			+ "        b = (x_ instanceof String y_) && (y_.length() > 0);\n"
+			+ "    }\n"
+			+ "}";
+
+	String selection = "y_";
+	String selectKey = "<SelectionOnLocalName:final String ";
+	String expectedSelection = selectKey + selection + ">;";
+
+	String selectionIdentifier = "y_";
+	String expectedUnitDisplayString =
+			"public class X {\n" +
+					"  public X() {\n" +
+					"  }\n" +
+					"  public @SuppressWarnings(\"preview\") void f(Object obj, boolean b) {\n" +
+					"    <SelectionOnLocalName:final String y_>;\n" +
+					"  }\n" +
+					"}\n";
+	String expectedReplacedSource = "y_";
+	String testName = "X.java";
+
+	int selectionStart = string.indexOf(selection);
+	int selectionEnd = string.indexOf(selection) + selection.length() - 1;
+
+	checkMethodParse(string.toCharArray(), selectionStart, selectionEnd, expectedSelection, expectedUnitDisplayString,
+			selectionIdentifier, expectedReplacedSource, testName);
+}
 }
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 73d48ab..75f1d13 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
@@ -1350,6 +1350,7 @@
 	    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("RecordIllegalModifierForLocalRecord", 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));
@@ -3017,6 +3018,7 @@
 	    expectedProblemAttributes.put("RecordCannotDefineRecordInLocalType",SKIP);
 	    expectedProblemAttributes.put("RecordMissingExplicitConstructorCallInNonCanonicalConstructor",SKIP);
 	    expectedProblemAttributes.put("RecordIllegalStaticModifierForLocalClassOrInterface", SKIP);
+	    expectedProblemAttributes.put("RecordIllegalModifierForLocalRecord", SKIP);
 	    expectedProblemAttributes.put("RecordComponentsCannotHaveModifiers",SKIP);
 	    expectedProblemAttributes.put("RecordIllegalParameterNameInCanonicalConstructor",SKIP);
 	    expectedProblemAttributes.put("RecordIllegalExplicitFinalFieldAssignInCompactConstructor",SKIP);
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 9031689..e3c6a1b 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
@@ -7878,4 +7878,52 @@
 		"Type mismatch: cannot convert from Margin to int\n" +
 		"----------\n");
 }
+public void testBug567731_001() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"  non-sealed record R() {}\n" +
+			"  public static void main(String[] args) {\n" +
+			"	  sealed record B() { }  \n" +
+			"  }" +
+			"}\n"
+		},
+		"----------\n" +
+		"1. ERROR in X.java (at line 2)\n" +
+		"	non-sealed record R() {}\n" +
+		"	                  ^\n" +
+		"Illegal modifier for the record R; only public, private, protected, static, final and strictfp are permitted\n" +
+		"----------\n" +
+		"2. ERROR in X.java (at line 4)\n" +
+		"	sealed record B() { }  \n" +
+		"	              ^\n" +
+		"Illegal modifier for the local record B; only final and strictfp are permitted\n" +
+		"----------\n"
+	);
+}
+public void testBug567731_002() {
+	this.runNegativeTest(
+		new String[] {
+			"X.java",
+			"public class X {\n" +
+			"  sealed record R1() {}\n" +
+			"  public static void main(String[] args) {\n" +
+			"	  non-sealed record R2() { }  \n" +
+			"  }" +
+			"}\n"
+		},
+		"----------\n" +
+		"1. ERROR in X.java (at line 2)\n" +
+		"	sealed record R1() {}\n" +
+		"	              ^^\n" +
+		"Illegal modifier for the record R1; only public, private, protected, static, final and strictfp are permitted\n" +
+		"----------\n" +
+		"2. ERROR in X.java (at line 4)\n" +
+		"	non-sealed record R2() { }  \n" +
+		"	                  ^^\n" +
+		"Illegal modifier for the local record R2; only final and strictfp are permitted\n" +
+		"----------\n"
+	);
+}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index fe3efb1..80a8a1d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -13218,4 +13218,17 @@
 		"	);\n" +
 		"}");
 }
+/**
+ * https://bugs.eclipse.org/567714 - [15] Formatting record file moves annotation to the line of record declaration
+ */
+public void testBug567714() {
+	formatSource(
+		"@SuppressWarnings(\"preview\")\n" +
+		"@Deprecated\n" +
+		"public record X(int i) {\n" +
+		"	public X(int i) {\n" +
+		"		this.i = i;\n" +
+		"	}\n" +
+		"}");
+}
 }
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java
index 21a7dd6..4144c5c 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests12To15.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * 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
@@ -723,4 +723,25 @@
 		elements
 	);
 }
+public void testBug553149_6() throws JavaModelException {
+	this.wc = getWorkingCopy("/Resolve15/src/X.java",
+			"public class X {\n"
+					+ "    @SuppressWarnings(\"preview\")\n"
+					+ "	   public void f(Object obj, boolean b) {\n"
+					+ "        if ((y instanceof String /*not selecting */x_) && /* selecting*/x_.length() > 0) {\n"
+					+ "            System.out.println(x_.toLowerCase());\n"
+					+ "        }\n"
+					+ "    }\n"
+					+ "}");
+	String str = this.wc.getSource();
+	String selection = "x_";
+	int start = str.indexOf(selection);
+	int length = "x_".length();
+	IJavaElement[] elements = this.wc.codeSelect(start, length);
+	assertElementsEqual(
+		"Unexpected elements",
+		"x_ [in f(Object, boolean) [in X [in [Working copy] X.java [in <default> [in src [in Resolve15]]]]]]",
+		elements
+	);
+}
 }
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index 538f807..1de7f9e 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
@@ -830,8 +830,12 @@
 			// Push only when the selection node is not the expression of this
 			// pattern matching instanceof expression
 			pushOnAstStack(typeDecl);
-		}
-		if (indexOfAssistIdentifier() >= 0) {
+			if ((this.selectionStart >= typeDecl.sourceStart)
+					&&  (this.selectionEnd <= typeDecl.sourceEnd)) {
+				this.restartRecovery	= true;
+				this.lastIgnoredToken = -1;
+			}
+		} else if (indexOfAssistIdentifier() >= 0) {
 			this.isOrphanCompletionNode = true;
 			this.restartRecovery = true;
 			this.lastIgnoredToken = -1;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index af13e88..125aecd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -2820,6 +2820,9 @@
 	/** @since 3.24
 	 * @noreference preview feature error */
 	int RecordIllegalStaticModifierForLocalClassOrInterface = PreviewRelated + 1761;
+	/** @since 3.24
+	 * @noreference preview feature error */
+	int RecordIllegalModifierForLocalRecord = PreviewRelated + 1762;
 
 	/** @since 3.24
 	 * @noreference preview feature error */
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index ae6b544..f48d45c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -1313,19 +1313,18 @@
 					modifiers |= ExtraCompilerModifiers.AccSealed;
 			}
 		} else if (sourceType.isRecord()) {
+			int UNEXPECTED_MODIFIERS = ExtraCompilerModifiers.AccNonSealed | ExtraCompilerModifiers.AccSealed;
 			if (isMemberType) {
-				final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp);
-				if ((realModifiers & UNEXPECTED_MODIFIERS) != 0)
+				final int EXPECTED_MODIFIERS = (ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp);
+				if ((realModifiers & ~EXPECTED_MODIFIERS) != 0 || (modifiers & UNEXPECTED_MODIFIERS) != 0)
 					problemReporter().illegalModifierForInnerRecord(sourceType);
 			} else if (sourceType.isLocalType()) {
-				final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccAbstract | ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp | ClassFileConstants.AccStatic);
-				if ((realModifiers & UNEXPECTED_MODIFIERS) != 0)
-					problemReporter().illegalModifierForLocalClass(sourceType);
+				final int EXPECTED_MODIFIERS = (ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp | ClassFileConstants.AccStatic);
+				if ((realModifiers & ~EXPECTED_MODIFIERS) != 0 || (modifiers & UNEXPECTED_MODIFIERS) != 0)
+					problemReporter().illegalModifierForLocalRecord(sourceType);
 			} else {
-				final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic |  ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp);
-				if ((realModifiers & UNEXPECTED_MODIFIERS) != 0
-						|| (modifiers & ExtraCompilerModifiers.AccNonSealed) != 0
-						|| (modifiers & ExtraCompilerModifiers.AccSealed) != 0)
+				final int EXPECTED_MODIFIERS = (ClassFileConstants.AccPublic |  ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp);
+				if ((realModifiers & ~EXPECTED_MODIFIERS) != 0 || (modifiers & UNEXPECTED_MODIFIERS) != 0)
 					problemReporter().illegalModifierForRecord(sourceType);
 			}
 			// JLS 14 8.10 : It is a compile-time error if a record declaration has the modifier abstract.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 674a84f..8a1df59 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -16023,6 +16023,17 @@
 		statement.sourceStart,
 		statement.sourceEnd);
 }
+public void illegalModifierForLocalRecord(SourceTypeBinding type) {
+	if (!this.options.enablePreviewFeatures)
+		return;
+	String[] arguments = new String[] {new String(type.sourceName())};
+	this.handle(
+		IProblem.RecordIllegalModifierForLocalRecord,
+		arguments,
+		arguments,
+		type.sourceStart(),
+		type.sourceEnd());
+}
 public void illegalModifierForInnerRecord(SourceTypeBinding type) {
 	if (!this.options.enablePreviewFeatures)
 		return;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index fe5701c..2c32b67 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -1059,6 +1059,7 @@
 1759 = Illegal explicit assignment of a final field {0} in compact constructor
 1760 = A non-canonical constructor must start with an explicit invocation to a constructor
 1761 = A local interface, enum or record {0} is implicitly static; cannot have explicit static declaration
+1762 = Illegal modifier for the local record {0}; only final and strictfp are permitted
 
 1765 = Illegal modifier for the local interface {0}; abstract and strictfp are the only modifiers allowed explicitly 
  
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
index 9072bf7..ed5158a 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
@@ -295,6 +295,7 @@
 
 	@Override
 	public boolean visit(RecordDeclaration node) {
+		handleAnnotations(node.modifiers(), this.options.insert_new_line_after_annotation_on_type);
 		handleBracedCode(node, node.getName(), this.options.brace_position_for_record_declaration,
 				this.options.indent_body_declarations_compare_to_record_header);
 		handleBodyDeclarations(node.bodyDeclarations());
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
index 23d069c..f3919c4 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2014, 2019 Mateusz Matela and others.
+ * Copyright (c) 2014, 2020 Mateusz Matela and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -349,6 +349,8 @@
 
 	@Override
 	public boolean visit(RecordDeclaration node) {
+		handleAnnotations(node.modifiers(), this.options.alignment_for_annotations_on_type);
+
 		int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN);
 		List<SingleVariableDeclaration> components = node.recordComponents();
 		int rParen = this.tm.firstIndexAfter(