diff options
author | Manoj Palat | 2021-04-27 15:41:49 +0000 |
---|---|---|
committer | Manoj Palat | 2021-04-28 09:20:32 +0000 |
commit | 0d7e21a3d5f8d2967cb621146a8a5a3e010c9ab1 (patch) | |
tree | 23ba3005aa9c6c9763030e6b11f71707c683b3a9 | |
parent | bc061ab235fc554c2c5ab1a0746361f46ed36ffa (diff) | |
download | eclipse.jdt.core-0d7e21a3d5f8d2967cb621146a8a5a3e010c9ab1.tar.gz eclipse.jdt.core-0d7e21a3d5f8d2967cb621146a8a5a3e010c9ab1.tar.xz eclipse.jdt.core-0d7e21a3d5f8d2967cb621146a8a5a3e010c9ab1.zip |
Bug 573195 - [16][record] protected modifier missing in canonical
constructor
Change-Id: If99d44b6c8095ae4e448c0e9ee247edc47b3fa51
Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/179885
Tested-by: JDT Bot <jdt-bot@eclipse.org>
2 files changed, 31 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 bf095c448d..4cbfc2afd4 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,8 +29,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug550750_025"}; -// TESTS_NAMES = new String[] { "testBug570399_001"}; +// TESTS_NAMES = new String[] { "testBug73195_001"}; } public static Class<?> testClass() { @@ -8971,4 +8970,33 @@ public void testBug572934_003() { options.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.IGNORE); options.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, CompilerOptions.DISABLED); } +public void testBug573195_001() throws Exception { + runConformTest( + new String[] { + "X.java", + "public class X {\n"+ + " protected record R(int i) {\n"+ + " public R(int i, int j) {\n"+ + " this(i);\n"+ + " }\n"+ + " }\n"+ + " public static void main(String[] args) {\n"+ + " R r = new R(1, 2);\n"+ + " System.out.println(r.i());\n"+ + " }\n"+ + "}" + }, + "1"); + String expectedOutput = // constructor + " // Method descriptor #12 (I)V\n" + + " // Stack: 2, Locals: 2\n" + + " protected X$R(int arg0);\n" + + " 0 aload_0 [this]\n" + + " 1 invokespecial java.lang.Record() [36]\n" + + " 4 aload_0 [this]\n" + + " 5 iload_1 [arg0]\n" + + " 6 putfield X$R.i : int [20]\n" + + " 9 return\n"; + RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$R.class", ClassFileBytesDisassembler.SYSTEM); +} } 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 873cfd4e45..6607741b0f 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 @@ -447,7 +447,7 @@ public class SyntheticMethodBinding extends MethodBinding { SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass; assert declaringSourceType.isRecord(); this.declaringClass = declaringSourceType; - this.modifiers = declaringClass.modifiers & (ClassFileConstants.AccPublic|ClassFileConstants.AccPrivate); + this.modifiers = declaringClass.modifiers & (ClassFileConstants.AccPublic|ClassFileConstants.AccPrivate|ClassFileConstants.AccProtected); if (this.declaringClass.isStrictfp()) this.modifiers |= ClassFileConstants.AccStrictfp; this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved); |