diff options
author | Manoj Palat | 2020-07-10 07:13:07 +0000 |
---|---|---|
committer | Manoj Palat | 2020-07-10 07:13:07 +0000 |
commit | 9515ace2029e49da17c2ddf4c676400d5b6ae23e (patch) | |
tree | 021151efce33c7183bf94a00563f5f80969d75e1 | |
parent | 3382967b63a8a24a5d0854640cbbdbb726ec1552 (diff) | |
download | eclipse.jdt.core-9515ace2029e49da17c2ddf4c676400d5b6ae23e.tar.gz eclipse.jdt.core-9515ace2029e49da17c2ddf4c676400d5b6ae23e.tar.xz eclipse.jdt.core-9515ace2029e49da17c2ddf4c676400d5b6ae23e.zip |
inherit record access modifier
Change-Id: I953d4ca9f57029d5e134a9886f2dd09f2ee4c03e
Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
2 files changed, 74 insertions, 10 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 b99e667dd6..e25b8f4420 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 @@ -33,7 +33,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug550750"}; +// TESTS_NAMES = new String[] { "testBug565104"}; } public static Class<?> testClass() { @@ -3426,7 +3426,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" + @@ -3507,7 +3507,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" + @@ -3552,7 +3552,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" + @@ -3610,7 +3610,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" + @@ -3676,7 +3676,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" + @@ -3761,7 +3761,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" + @@ -4461,4 +4461,68 @@ public void testBug562637_001() { " \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); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java index c9b73bc9e0..1789600c77 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java @@ -387,9 +387,9 @@ public ConstructorDeclaration createDefaultConstructorForRecord(boolean needExpl ConstructorDeclaration constructor = new ConstructorDeclaration(this.compilationResult); constructor.bits |= ASTNode.IsCanonicalConstructor | ASTNode.IsImplicit; constructor.selector = this.name; -// constructor.modifiers = this.modifiers & ExtraCompilerModifiers.AccVisibilityMASK; - constructor.modifiers = this.modifiers & ClassFileConstants.AccPublic; - constructor.modifiers |= ClassFileConstants.AccPublic; // JLS 14 8.10.5 + constructor.modifiers = this.modifiers & ExtraCompilerModifiers.AccVisibilityMASK; +// constructor.modifiers = this.modifiers & ClassFileConstants.AccPublic; +// constructor.modifiers |= ClassFileConstants.AccPublic; // JLS 14 8.10.5 constructor.arguments = getArgumentsFromComponents(this.recordComponents); constructor.declarationSourceStart = constructor.sourceStart = |