langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java
changeset 24896 986d876a9121
parent 24292 12414a72f8d2
child 30730 d3ce7619db2c
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java	Fri Jun 06 16:00:59 2014 -0400
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java	Fri Jun 06 16:08:46 2014 -0400
@@ -25,7 +25,7 @@
 
 /*
  * @test
- * @bug 8013852
+ * @bug 8013852 8042451
  * @summary Test population of reference info for instance and class initializers
  * @author Werner Dietl
  * @compile -g Driver.java ReferenceInfoUtil.java Initializers.java
@@ -33,63 +33,98 @@
  */
 public class Initializers {
 
-    @TADescriptions({
-        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TB", type = NEW,
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TB", type = NEW,
                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
-    })
-    public String instanceInit1() {
-        return "class Test { { Object o = new @TA ArrayList<@TB String>(); } }";
+        public String instanceInit1() {
+        return "class %TEST_CLASS_NAME% { { Object o = new @TA ArrayList<@TB String>(); } }";
     }
 
-    @TADescriptions({
-        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TB", type = NEW,
-                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TD", type = NEW,
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TB", type = NEW,
                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
-    })
-    public String instanceInit2() {
-        return "class Test { Object f = new @TA ArrayList<@TB String>(); " +
+    @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TD", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+        public String instanceInit2() {
+        return "class %TEST_CLASS_NAME% { Object f = new @TA ArrayList<@TB String>(); " +
                 " { Object o = new @TC ArrayList<@TD String>(); } }";
     }
 
-    @TADescriptions({
-        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TB", type = NEW,
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TB", type = NEW,
                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
-    })
-    public String staticInit1() {
-        return "class Test { static { Object o = new @TA ArrayList<@TB String>(); } }";
+        public String staticInit1() {
+        return "class %TEST_CLASS_NAME% { static { Object o = new @TA ArrayList<@TB String>(); } }";
     }
 
-    @TADescriptions({
-        @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TB", type = NEW,
-                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TD", type = NEW,
-                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE),
-        @TADescription(annotation = "TF", type = NEW,
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TB", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TD", type = NEW,
                 genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
-    })
-    public String staticInit2() {
-        return "class Test { Object f = new @TA ArrayList<@TB String>(); " +
+    @TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "TF", type = NEW,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+        public String staticInit2() {
+        return "class %TEST_CLASS_NAME% { Object f = new @TA ArrayList<@TB String>(); " +
                 " static Object g = new @TC ArrayList<@TD String>(); " +
                 " static { Object o = new @TE ArrayList<@TF String>(); } }";
     }
 
-    // TODO: test interaction with several constructors, especially non-initial constuctors.
+    @TADescription(annotation = "TA", type = CAST,
+                typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE)
+        public String lazyConstantCast1() {
+        return "class %TEST_CLASS_NAME% { public static final Object o = (@TA Object) null; }";
+    }
+
+    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTBs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String instanceInitRepeatableAnnotation1() {
+        return "class %TEST_CLASS_NAME% { { Object o = new @RTA @RTA ArrayList<@RTB @RTB String>(); } }";
+    }
+
+    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTBs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTDs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String instanceInitRepeatableAnnotation2() {
+        return "class %TEST_CLASS_NAME% { Object f = new @RTA @RTA ArrayList<@RTB @RTB String>(); " +
+                " { Object o = new @RTC @RTC ArrayList<@RTD @RTD String>(); } }";
+    }
+
+    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTBs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String staticInitRepeatableAnnotation1() {
+        return "class %TEST_CLASS_NAME% { static { Object o = new @RTA @RTA ArrayList<@RTB @RTB String>(); } }";
+    }
+
+    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTBs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTDs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTEs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    @TADescription(annotation = "RTFs", type = NEW,
+            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String staticInitRepeatableAnnotation2() {
+        return "class %TEST_CLASS_NAME% { Object f = new @RTA @RTA ArrayList<@RTB @RTB String>(); " +
+                " static Object g = new @RTC @RTC ArrayList<@RTD @RTD String>(); " +
+                " static { Object o = new @RTE @RTE ArrayList<@RTF @RTF String>(); } }";
+    }
+
+    // TODO: test interaction with several constructors, especially non-initial constructors.
     // I don't think this kind of test is possible here.
 
-    @TADescriptions({
-        @TADescription(annotation = "TA", type = CAST,
-                typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE),
-    })
-    public String lazyConstantCast1() {
-        return "class Test { public static final Object o = (@TA Object) null; }";
+    @TADescription(annotation = "RTAs", type = CAST,
+            typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String lazyConstantCastRepeatableAnnotation1() {
+        return "class %TEST_CLASS_NAME% { public static final Object o = (@RTA @RTA Object) null; }";
     }
-
 }