diff options
author | Sravan Kumar Lakkimsetti | 2021-07-12 15:38:31 +0000 |
---|---|---|
committer | Manoj Palat | 2021-07-14 06:44:04 +0000 |
commit | babe1983d5525af86b2460b0c142367cad3f520c (patch) | |
tree | 96b25bee525caca8f775080bd47b5c380d6b2b98 | |
parent | 27b82ba28ad8b5d6dc509c7a2667cc3a62f8834e (diff) | |
download | eclipse.jdt.core-babe1983d5525af86b2460b0c142367cad3f520c.tar.gz eclipse.jdt.core-babe1983d5525af86b2460b0c142367cad3f520c.tar.xz eclipse.jdt.core-babe1983d5525af86b2460b0c142367cad3f520c.zip |
Change-Id: I2e7ceed8941079236498a83989b9224172b3d416
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/182995
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Manoj Palat <manpalat@in.ibm.com>
2 files changed, 58 insertions, 1 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 4cbfc2afd4..d4ee4ce99e 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,7 +29,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug73195_001"}; +// TESTS_NAMES = new String[] { "testBug574284"}; } public static Class<?> testClass() { @@ -8999,4 +8999,58 @@ public void testBug573195_001() throws Exception { " 9 return\n"; RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$R.class", ClassFileBytesDisassembler.SYSTEM); } +public void testBug574284_001() throws Exception { + runConformTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X.Rec(false); // fails\n" + + " new X.Rec(false, new int[0]);\n" + + " System.out.println(0);\n" + + " }\n" + + "\n" + + " record Rec(boolean isHidden, int... indexes) {\n" + + " Rec(int... indexes) {\n" + + " this(false, indexes);\n" + + " }\n" + + " }\n" + + "}" + }, + "0"); + String expectedOutput = // constructor + " // Method descriptor #14 (Z[I)V\n" + + " // Stack: 2, Locals: 3\n" + + " X$Rec(boolean arg0, int... arg1);\n" + + " 0 aload_0 [this]\n" + + " 1 invokespecial java.lang.Record() [41]\n" + + " 4 aload_0 [this]\n" + + " 5 iload_1 [arg0]\n" + + " 6 putfield X$Rec.isHidden : boolean [21]\n" + + " 9 aload_0 [this]\n" + + " 10 aload_2 [arg1]\n" + + " 11 putfield X$Rec.indexes : int[] [24]\n" + + " 14 return\n"; + RecordsRestrictedClassTest.verifyClassFile(expectedOutput, "X$Rec.class", ClassFileBytesDisassembler.SYSTEM); + +} +public void testBug574284_002() { + runConformTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X.Rec(false); // fails\n" + + " new X.Rec(false, new int[0]);\n" + + " System.out.println(0);\n" + + " }\n" + + "\n" + + " record Rec(boolean isHidden, int... indexes) {\n" + + " }\n" + + "}" + }, + "0"); +} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java index 87cbdac9ef..19caba18e7 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java @@ -1429,6 +1429,9 @@ public RecordComponentBinding[] components() { for (int i = 0, l = smb.parameters.length; i < l; ++i) { smb.parameters[i] = this.components[i].type; } + if (this.isVarArgs == true) { + smb.modifiers |= ClassFileConstants.AccVarargs; + } } } } |