Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-05-14 18:17:08 +0000
committerManoj Palat2020-05-18 05:02:00 +0000
commitde8e219ad10c11359647671dcbf6a9473605425f (patch)
tree34986c4551d248297b6ce91c6e8d0c7096f1442c
parentc2dc07f83f3f21e96b226d4352c46c837e16e078 (diff)
downloadeclipse.jdt.core-manoj_sealed_360.tar.gz
eclipse.jdt.core-manoj_sealed_360.tar.xz
eclipse.jdt.core-manoj_sealed_360.zip
Bug 561807 - [15] [compiler] Records - missing final modifier formanoj_sealed_360
synthetic toString() Change-Id: Ib10c7faad43800bc18f0f48a15022f5770d9fa01
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java16
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java8
2 files changed, 21 insertions, 3 deletions
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 100b4287d5..082c05d12f 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
@@ -2434,6 +2434,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[] {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java
index 53cece980a..3ebe9e6dd5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java
@@ -8,6 +8,10 @@
*
* SPDX-License-Identifier: EPL-2.0
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
@@ -469,7 +473,7 @@ public class SyntheticMethodBinding extends MethodBinding {
SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass;
assert declaringSourceType.isRecord();
this.declaringClass = declaringSourceType;
- this.modifiers = ClassFileConstants.AccPublic;
+ this.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccFinal;
if (this.declaringClass.isStrictfp())
this.modifiers |= ClassFileConstants.AccStrictfp;
this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
@@ -480,12 +484,10 @@ public class SyntheticMethodBinding extends MethodBinding {
this.parameters = Binding.NO_PARAMETERS;
this.purpose = SyntheticMethodBinding.RecordOverrideToString;
} else if (selector == TypeConstants.HASHCODE) {
- this.modifiers |= ClassFileConstants.AccFinal;
this.returnType = TypeBinding.INT;
this.parameters = Binding.NO_PARAMETERS;
this.purpose = SyntheticMethodBinding.RecordOverrideHashCode;
} else if (selector == TypeConstants.EQUALS) {
- this.modifiers |= ClassFileConstants.AccFinal;
this.returnType = TypeBinding.BOOLEAN;
this.parameters = new TypeBinding[] {declaringSourceType.scope.getJavaLangObject()};
this.purpose = SyntheticMethodBinding.RecordOverrideEquals;

Back to the top