1/* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24package typeannos; 25 26import java.lang.annotation.*; 27import static java.lang.annotation.ElementType.*; 28 29/* 30 * This class is partially replicated from test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java; CombinationsTargetTest2.java; CombinationsTargetTest3.java 31 */ 32@RepTypeA @RepTypeA @RepTypeB @RepTypeB class RepeatingAtClassLevel { 33} 34 35@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB class RepeatingAtClassLevel2 { 36} 37 38@RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB class RepeatingAtClassLevel3 { 39} 40 41class RepeatingOnConstructor { 42 43 @RepConstructorA @RepConstructorA @RepConstructorB @RepConstructorB 44 RepeatingOnConstructor() { 45 } 46 47 @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor(int i) { 48 } 49 50 @RepConstructorA @RepConstructorA @RepConstructorB @RepConstructorB 51 @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor(int i, int j) { 52 } 53 54 @RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB RepeatingOnConstructor(int i, int j, int k) { 55 } 56 57 RepeatingOnConstructor(@RepParameterA @RepParameterA @RepParameterB @RepParameterB String parameter, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB ... vararg) { 58 } 59 60 class Inner { 61 Inner(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor RepeatingOnConstructor.this, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String parameter, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB ... vararg) { 62 } 63 } 64} 65 66class RepeatingOnField { 67 @RepFieldA @RepFieldA @RepFieldB @RepFieldB 68 Integer i1; 69 70 @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Integer i2; 71 72 @RepFieldA @RepFieldA @RepFieldB @RepFieldB 73 @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Integer i3; 74 75 @RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB Integer i4; 76 77 String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB [] @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB [] sa = null; 78} 79 80class RepeatingOnMethod { 81 82 @RepMethodA @RepMethodA @RepMethodB @RepMethodB 83 String test1() { 84 return null; 85 } 86 87 @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB String test2() { 88 return null; 89 } 90 91 @RepMethodA @RepMethodA @RepMethodB @RepMethodB 92 @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB String test3() { 93 return null; 94 } 95 96 @RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB String test4() { 97 return null; 98 } 99 100 String test5(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnMethod this, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String parameter, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB ... vararg) { 101 return null; 102 } 103} 104 105class RepeatingOnTypeParametersBoundsTypeArgumentsOnClassDecl <@RepTypeParameterA @RepTypeParameterA @RepTypeParameterB @RepTypeParameterB T extends @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Object> { 106 107 <T> String genericMethod(T t) { 108 return null; 109 } 110} 111 112class RepeatingOnTypeParametersBoundsTypeArgumentsOnClassDecl2 <@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T extends @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Object> { 113 114 <T> String genericMethod(T t) { 115 return null; 116 } 117} 118 119class RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod <T extends Object> { 120 121 String test(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod<@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T> this) { 122 return null; 123 } 124 125 <@RepTypeParameterA @RepTypeParameterA @RepTypeParameterB @RepTypeParameterB T> String genericMethod(@RepParameterA @RepParameterA @RepParameterB @RepParameterB T t) { 126 return null; 127 } 128 129 <@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T> String genericMethod2(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T t) { 130 return null; 131 } 132} 133 134class RepeatingOnVoidMethodDeclaration { 135 136 @RepMethodA @RepMethodA @RepMethodB @RepMethodB void test() {} 137} 138 139class RepeatingOnStaticMethodOfInterface { 140 141 interface I { 142 static @RepMethodA @RepMethodA @RepMethodB @RepMethodB String m() { 143 return null; 144 } 145 } 146} 147 148//------------------------------------------------------------------------------ 149@Target({TYPE}) 150@Repeatable(ContTypeA.class) 151@Documented 152@interface RepTypeA { } 153 154@Target({TYPE}) 155@Documented 156@interface ContTypeA { RepTypeA[] value(); } 157 158@Target({TYPE}) 159@Repeatable(ContTypeB.class) 160@Documented 161@interface RepTypeB { } 162 163@Target({TYPE}) 164@Documented 165@interface ContTypeB { RepTypeB[] value(); } 166 167//------------------------------------------------------------------------------ 168@Target({CONSTRUCTOR}) 169@Repeatable(ContConstructorA.class) 170@Documented 171@interface RepConstructorA { } 172 173@Target({CONSTRUCTOR}) 174@Documented 175@interface ContConstructorA { RepConstructorA[] value(); } 176 177@Target({CONSTRUCTOR}) 178@Repeatable(ContConstructorB.class ) 179@Documented 180@interface RepConstructorB { } 181 182@Target({CONSTRUCTOR}) 183@Documented 184@interface ContConstructorB { RepConstructorB[] value(); } 185 186//------------------------------------------------------------------------------ 187@Target({METHOD}) 188@Repeatable(ContMethodA.class) 189@Documented 190@interface RepMethodA {} 191 192@Target({METHOD}) 193@Documented 194@interface ContMethodA { 195 RepMethodA[] value(); 196} 197 198@Target({METHOD}) 199@Repeatable(ContMethodB.class) 200@Documented 201@interface RepMethodB {} 202 203@Target({METHOD}) 204@Documented 205@interface ContMethodB { 206 RepMethodB[] value(); 207} 208 209//------------------------------------------------------------------------------ 210@Target({FIELD}) 211@Repeatable(ContFieldA.class) 212@Documented 213@interface RepFieldA {} 214 215@Target({FIELD}) 216@Documented 217@interface ContFieldA { 218 RepFieldA[] value(); 219} 220 221@Target({FIELD}) 222@Repeatable(ContFieldB.class) 223@Documented 224@interface RepFieldB {} 225 226@Target({FIELD}) 227@Documented 228@interface ContFieldB { 229 RepFieldB[] value(); 230} 231 232//------------------------------------------------------------------------------ 233@Target({TYPE_USE}) 234@Repeatable(ContTypeUseA.class) 235@Documented 236@interface RepTypeUseA {} 237 238@Target({TYPE_USE}) 239@Documented 240@interface ContTypeUseA { 241 RepTypeUseA[] value(); 242} 243 244@Target({TYPE_USE}) 245@Repeatable(ContTypeUseB.class) 246@Documented 247@interface RepTypeUseB {} 248 249@Target({TYPE_USE}) 250@Documented 251@interface ContTypeUseB { 252 RepTypeUseB[] value(); 253} 254 255//------------------------------------------------------------------------------ 256@Target({TYPE_PARAMETER}) 257@Repeatable(ContTypeParameterA.class) 258@Documented 259@interface RepTypeParameterA {} 260 261@Target({TYPE_PARAMETER}) 262@Documented 263@interface ContTypeParameterA { 264 RepTypeParameterA[] value(); 265} 266 267@Target({TYPE_PARAMETER}) 268@Repeatable(ContTypeParameterB.class) 269@Documented 270@interface RepTypeParameterB {} 271 272@Target({TYPE_PARAMETER}) 273@Documented 274@interface ContTypeParameterB { 275 RepTypeParameterB[] value(); 276} 277 278//------------------------------------------------------------------------------ 279@Target({PARAMETER}) 280@Repeatable(ContParameterA.class) 281@Documented 282@interface RepParameterA {} 283 284@Target({PARAMETER}) 285@Documented 286@interface ContParameterA { 287 RepParameterA[] value(); 288} 289 290@Target({PARAMETER}) 291@Repeatable(ContParameterB.class) 292@Documented 293@interface RepParameterB {} 294 295@Target({PARAMETER}) 296@Documented 297@interface ContParameterB { 298 RepParameterB[] value(); 299} 300 301 302//------------------------------------------------------------------------------ 303@Target({PACKAGE}) 304@Repeatable(ContPackageA.class) 305@Documented 306@interface RepPackageA {} 307 308@Target({PACKAGE}) 309@Documented 310@interface ContPackageA { 311 RepPackageA[] value(); 312} 313 314@Target({PACKAGE}) 315@Repeatable(ContPackageB.class) 316@Documented 317@interface RepPackageB {} 318 319@Target({PACKAGE}) 320@Documented 321@interface ContPackageB { 322 RepPackageB[] value(); 323} 324 325//------------------------------------------------------------------------------ 326@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE}) 327@Repeatable(ContAllContextsA.class) 328@Documented 329@interface RepAllContextsA {} 330 331@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE}) 332@Documented 333@interface ContAllContextsA { 334 RepAllContextsA[] value(); 335} 336 337@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE}) 338@Repeatable(ContAllContextsB.class) 339@Documented 340@interface RepAllContextsB {} 341 342@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE}) 343@Documented 344@interface ContAllContextsB { 345 RepAllContextsB[] value(); 346} 347