test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java

Print this page




 154         String As = "@A", Bs = "@B", Ds = "@D";
 155         if(Arepeats) As = "@A @A";
 156         if(BDrepeats) {
 157             Bs = "@B @B";
 158             Ds = "@D @D";
 159         }
 160         if(ABmix) { As = "@A @B"; Bs = "@A @B"; Ds = "@D @D"; }
 161 
 162         // Source to check for TYPE_USE and TYPE_PARAMETER annotations.
 163         // Source base (annotations) is same for all test cases.
 164         String source = new String();
 165         String imports = new String("import java.lang.annotation.*; \n" +
 166             "import static java.lang.annotation.RetentionPolicy.*; \n" +
 167             "import static java.lang.annotation.ElementType.*; \n" +
 168             "import java.util.List; \n" +
 169             "import java.util.HashMap; \n" +
 170             "import java.util.Map; \n\n");
 171 
 172             String sourceBase = new String("@Retention("+retentn+")\n" +
 173             "@Target({TYPE_USE,_OTHER_})\n" +
 174             "@ContainedBy( AC.class )\n" +
 175             "@interface A { }\n\n" +
 176 
 177             "@Retention("+retentn+")\n" +
 178             "@Target({TYPE_USE,_OTHER_})\n" +
 179             "@ContainerFor(A.class)\n" +
 180             "@interface AC { A[] value(); }\n\n" +
 181 
 182             "@Retention("+retentn+")\n" +
 183             "@Target({TYPE_USE,_OTHER_})\n" +
 184             "@ContainedBy( BC.class )\n" +
 185             "@interface B { }\n\n" +
 186 
 187             "@Retention("+retentn+")\n" +
 188             "@Target({TYPE_USE,_OTHER_})\n" +
 189             "@ContainerFor(B.class)\n" +
 190             "@interface BC { B[] value(); } \n\n" +
 191 
 192             "@Retention("+retentn+")\n" +
 193             "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
 194             "@ContainedBy(DC.class)\n" +
 195             "@interface D { }\n\n" +
 196 
 197             "@Retention("+retentn+")\n" +
 198             "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
 199             "@ContainerFor(D.class) \n" +
 200             "@interface DC { D[] value(); }\n\n");
 201 
 202         // Test case sources with sample generated source
 203         switch(src) {
 204             case 3: // (repeating) type annotations on field in method body
 205                     /*
 206                      * class Test1 {
 207                      * Test1(){}
 208                      * // type usage in method body
 209                      * String test(Test1 this, String param, String ... vararg) {
 210                      *     @A @B
 211                      *     Object o = new @A @B  String @A @B  [3];
 212                      *         return (@A @B  String) null;
 213                      * }}
 214                       */
 215                 source = new String(
 216                 "class " + testname + " {\n" +
 217                 "" + testname +"(){} \n" +
 218                 "// type usage in method body \n" +
 219                 "String test("+testname+" this, " +




 154         String As = "@A", Bs = "@B", Ds = "@D";
 155         if(Arepeats) As = "@A @A";
 156         if(BDrepeats) {
 157             Bs = "@B @B";
 158             Ds = "@D @D";
 159         }
 160         if(ABmix) { As = "@A @B"; Bs = "@A @B"; Ds = "@D @D"; }
 161 
 162         // Source to check for TYPE_USE and TYPE_PARAMETER annotations.
 163         // Source base (annotations) is same for all test cases.
 164         String source = new String();
 165         String imports = new String("import java.lang.annotation.*; \n" +
 166             "import static java.lang.annotation.RetentionPolicy.*; \n" +
 167             "import static java.lang.annotation.ElementType.*; \n" +
 168             "import java.util.List; \n" +
 169             "import java.util.HashMap; \n" +
 170             "import java.util.Map; \n\n");
 171 
 172             String sourceBase = new String("@Retention("+retentn+")\n" +
 173             "@Target({TYPE_USE,_OTHER_})\n" +
 174             "@Repeatable( AC.class )\n" +
 175             "@interface A { }\n\n" +
 176 
 177             "@Retention("+retentn+")\n" +
 178             "@Target({TYPE_USE,_OTHER_})\n" +

 179             "@interface AC { A[] value(); }\n\n" +
 180 
 181             "@Retention("+retentn+")\n" +
 182             "@Target({TYPE_USE,_OTHER_})\n" +
 183             "@Repeatable( BC.class )\n" +
 184             "@interface B { }\n\n" +
 185 
 186             "@Retention("+retentn+")\n" +
 187             "@Target({TYPE_USE,_OTHER_})\n" +

 188             "@interface BC { B[] value(); } \n\n" +
 189 
 190             "@Retention("+retentn+")\n" +
 191             "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
 192             "@Repeatable(DC.class)\n" +
 193             "@interface D { }\n\n" +
 194 
 195             "@Retention("+retentn+")\n" +
 196             "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +

 197             "@interface DC { D[] value(); }\n\n");
 198 
 199         // Test case sources with sample generated source
 200         switch(src) {
 201             case 3: // (repeating) type annotations on field in method body
 202                     /*
 203                      * class Test1 {
 204                      * Test1(){}
 205                      * // type usage in method body
 206                      * String test(Test1 this, String param, String ... vararg) {
 207                      *     @A @B
 208                      *     Object o = new @A @B  String @A @B  [3];
 209                      *         return (@A @B  String) null;
 210                      * }}
 211                       */
 212                 source = new String(
 213                 "class " + testname + " {\n" +
 214                 "" + testname +"(){} \n" +
 215                 "// type usage in method body \n" +
 216                 "String test("+testname+" this, " +