From ce4978ffe69c20f9e6adb13944ea4c30c912f6a4 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 17 Jun 2020 13:19:51 -0400 Subject: [PATCH] 8246257: Annotated record's vararg type component started to be uncompilable with JDK15b24 Reviewed-by: jjg, jlaskey --- .../sun/tools/javac/code/TypeAnnotations.java | 3 +++ .../javac/records/RecordCompilationTests.java | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index dd7662fdb9a..173aa65b611 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -548,6 +548,9 @@ public class TypeAnnotations { */ private Type rewriteArrayType(ArrayType type, List annotations, TypeAnnotationPosition pos) { ArrayType tomodify = new ArrayType(type); + if (type.isVarargs()) { + tomodify = tomodify.makeVarargs(); + } ArrayType res = tomodify; List loc = List.nil(); diff --git a/test/langtools/tools/javac/records/RecordCompilationTests.java b/test/langtools/tools/javac/records/RecordCompilationTests.java index d721ff8d147..c88307af46a 100644 --- a/test/langtools/tools/javac/records/RecordCompilationTests.java +++ b/test/langtools/tools/javac/records/RecordCompilationTests.java @@ -1130,6 +1130,26 @@ public class RecordCompilationTests extends CompilationTestCase { this.args = args; } } + """, + """ + record R(@A int... ints) {} + + @java.lang.annotation.Target({ + java.lang.annotation.ElementType.TYPE_USE, + java.lang.annotation.ElementType.RECORD_COMPONENT}) + @interface A {} + """, + """ + record R(@A int... ints) { + R(@A int... ints) { + this.ints = ints; + } + } + + @java.lang.annotation.Target({ + java.lang.annotation.ElementType.TYPE_USE, + java.lang.annotation.ElementType.RECORD_COMPONENT}) + @interface A {} """ )) { assertOK(source);