Thu, 23 Jan 2014 11:59:06 -0800
8027477: Enable repeating annotations test cases since JDK-8004912 is fixed
Reviewed-by: jjg
Contributed-by: matherey.nunez@oracle.com
test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java | file | annotate | diff | comparison | revisions |
1.1 --- a/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java Thu Jan 16 23:52:44 2014 +0000 1.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java Thu Jan 23 11:59:06 2014 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -23,7 +23,7 @@ 1.11 1.12 /** 1.13 * @test 1.14 - * @bug 8001457 1.15 + * @bug 8001457 8027477 1.16 * @author sogoel 1.17 * @summary Reflection api tests 1.18 * @build Helper 1.19 @@ -159,7 +159,12 @@ 1.20 "SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy", 1.21 "ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy", 1.22 "SingleAnnoWithContainer", 1.23 - "SingleOnSuperContainerAndSingleOnSub_Inherited"); 1.24 + "SingleOnSuperContainerAndSingleOnSub_Inherited", 1.25 + "RepeatableOnSuperSingleOnSub_Inherited", 1.26 + "SingleOnSuperRepeatableOnSub_Inherited", 1.27 + "ContainerOnSuperSingleOnSub_Inherited", 1.28 + "SingleOnSuperContainerOnSub_Inherited", 1.29 + "ContainerAndSingleOnSuperSingleOnSub_Inherited"); 1.30 if (orderingTestFailures.contains(testCase.toString())) { 1.31 CHECKORDERING = false; 1.32 } else 1.33 @@ -1612,323 +1617,323 @@ 1.34 return files; 1.35 } 1.36 }, 1.37 -// // Testcase not working as expected, JDK-8004912 1.38 -// RepeatableOnSuperSingleOnSub_Inherited( 1.39 -// "@ExpectedBase(value=Foo.class, " 1.40 -// + "getAnnotationVal = \"Foo\", " 1.41 -// + "getAnnotationsVals = {" 1.42 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.43 -// + //override every annotation on superClass 1.44 -// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, " 1.45 -// + // ignores inherited annotations 1.46 -// "getDeclAnnoVal = \"Foo\", " // ignores inherited 1.47 -// + "getAnnosArgs = {\"Foo\"}, " 1.48 -// + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited 1.49 -// "@ExpectedContainer(value=FooContainer.class, " 1.50 -// + "getAnnotationVal = \"FooContainer\", " 1.51 -// + "getAnnotationsVals = {" 1.52 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.53 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, " 1.54 -// + // ignores inherited annotations 1.55 -// "getDeclAnnoVal = \"NULL\", " 1.56 -// + "getAnnosArgs = {\"FooContainer\"}, " 1.57 -// + "getDeclAnnosArgs = {}) // ignores inherited ") { 1.58 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1.59 + // fail with ordering issues 1.60 + RepeatableOnSuperSingleOnSub_Inherited( 1.61 + "@ExpectedBase(value=Foo.class, " 1.62 + + "getAnnotationVal = \"@Foo(value=3)\", " 1.63 + + "getAnnotationsVals = {" 1.64 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.65 + + //override every annotation on superClass 1.66 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 1.67 + + // ignores inherited annotations 1.68 + "getDeclAnnoVal = \"@Foo(value=3)\", " // ignores inherited 1.69 + + "getAnnosArgs = {\"@Foo(value=3)\"}, " 1.70 + + "getDeclAnnosArgs = { \"@Foo(value=3)\" })", // ignores inherited 1.71 + "@ExpectedContainer(value=FooContainer.class, " 1.72 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1.73 + + "getAnnotationsVals = {" 1.74 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.75 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 1.76 + + // ignores inherited annotations 1.77 + "getDeclAnnoVal = \"NULL\", " 1.78 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.79 + + "getDeclAnnosArgs = {}) // ignores inherited ") { 1.80 1.81 -// @Override 1.82 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.83 -// String className) { 1.84 -// String anno = ""; 1.85 -// String replaceVal = ""; 1.86 -// String contents = ""; 1.87 -// JavaFileObject srcFileObj = null; 1.88 -// Iterable<? extends JavaFileObject> files = null; 1.89 + @Override 1.90 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.91 + String className) { 1.92 + String anno = ""; 1.93 + String replaceVal = ""; 1.94 + String contents = ""; 1.95 + JavaFileObject srcFileObj = null; 1.96 + Iterable<? extends JavaFileObject> files = null; 1.97 1.98 -// String expectedVals = "\n" + getExpectedBase() + "\n" 1.99 -// + getExpectedContainer() + "\n"; 1.100 -// StringBuilder commonStmts = getCommonStmts(true); 1.101 + String expectedVals = "\n" + getExpectedBase() + "\n" 1.102 + + getExpectedContainer() + "\n"; 1.103 + StringBuilder commonStmts = getCommonStmts(true); 1.104 1.105 -// /* 1.106 -// Sample testSrc: 1.107 -// @Retention(RetentionPolicy.RUNTIME) 1.108 -// @Inherited 1.109 -// @Repeatable(FooContainer.class) 1.110 -// @interface Foo {int value() default Integer.MAX_VALUE;} 1.111 + /* 1.112 + Sample testSrc: 1.113 + @Retention(RetentionPolicy.RUNTIME) 1.114 + @Inherited 1.115 + @Repeatable(FooContainer.class) 1.116 + @interface Foo {int value() default Integer.MAX_VALUE;} 1.117 1.118 -// @Retention(RetentionPolicy.RUNTIME) 1.119 -// @Inherited 1.120 -// @interface FooContainer { 1.121 -// Foo[] value(); 1.122 -// } 1.123 + @Retention(RetentionPolicy.RUNTIME) 1.124 + @Inherited 1.125 + @interface FooContainer { 1.126 + Foo[] value(); 1.127 + } 1.128 1.129 -// @Foo() @Foo 1.130 -// class SuperClass { } 1.131 + @Foo(1) @Foo(2) 1.132 + class SuperClass { } 1.133 1.134 -// @ExpectedBase 1.135 -// @ExpectedContainer 1.136 -// @Foo 1.137 -// class SubClass extends SuperClass { } 1.138 -// */ 1.139 -// //@Inherited only works for classes, no switch cases for method, field, package 1.140 + @ExpectedBase 1.141 + @ExpectedContainer 1.142 + @Foo(3) 1.143 + class SubClass extends SuperClass { } 1.144 + */ 1.145 + //@Inherited only works for classes, no switch cases for method, field, package 1.146 + if (srcType == SrcType.CLASS) { 1.147 + //Contents for SuperClass 1.148 + anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1.149 + replaceVal = commonStmts + "\n" + anno; 1.150 + String superClassContents = srcType.getTemplate() 1.151 + .replace("#CN", SUPERCLASS) 1.152 + .replace("#REPLACE", replaceVal); 1.153 1.154 -// if (srcType == SrcType.CLASS) { 1.155 -// //Contents for SuperClass 1.156 -// anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1.157 -// replaceVal = commonStmts + "\n" + anno; 1.158 -// String superClassContents = srcType.getTemplate() 1.159 -// .replace("#CN", SUPERCLASS) 1.160 -// .replace("#REPLACE", replaceVal); 1.161 + //Contents for SubClass that extends SuperClass 1.162 + anno = "@Foo(3)"; 1.163 + replaceVal = expectedVals + "\n" + anno; 1.164 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.165 + .replace("#CN", className) 1.166 + .replace("#SN", SUPERCLASS) 1.167 + .replace("#REPLACE", replaceVal); 1.168 + contents = superClassContents + subClassContents; 1.169 + srcFileObj = Helper.getFile(className, contents); 1.170 + files = Arrays.asList(srcFileObj); 1.171 + } 1.172 + return files; 1.173 + } 1.174 + }, 1.175 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1.176 + // fail with ordering issues 1.177 + SingleOnSuperRepeatableOnSub_Inherited( 1.178 + "@ExpectedBase(value=Foo.class, " 1.179 + + "getAnnotationVal = \"@Foo(value=0)\", " 1.180 + + "getAnnotationsVals = {" 1.181 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.182 + + //override every annotation on superClass 1.183 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.184 + + // ignores inherited annotations 1.185 + "getDeclAnnoVal = \"NULL\","// ignores inherited 1.186 + + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 1.187 + + "getDeclAnnosArgs = { \"@Foo(value=1)\", \"@Foo(value=2)\"})", 1.188 + "@ExpectedContainer(value=FooContainer.class, " 1.189 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1.190 + + "getAnnotationsVals = {" 1.191 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.192 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.193 + + // ignores inherited annotations 1.194 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "// ignores inherited 1.195 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.196 + + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1.197 1.198 -// //Contents for SubClass that extends SuperClass 1.199 -// anno = "@Foo(0)"; 1.200 -// replaceVal = expectedVals + "\n" + anno; 1.201 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.202 -// .replace("#CN", className) 1.203 -// .replace("#SN", SUPERCLASS) 1.204 -// .replace("#REPLACE", replaceVal); 1.205 -// contents = superClassContents + subClassContents; 1.206 -// srcFileObj = Helper.getFile(className, contents); 1.207 -// files = Arrays.asList(srcFileObj); 1.208 -// } 1.209 -// return files; 1.210 -// } 1.211 -// }, 1.212 -// //Testcase not working as expected, JDK-8004912 1.213 -// SingleOnSuperRepeatableOnSub_Inherited( 1.214 -// "@ExpectedBase(value=Foo.class, " 1.215 -// + "getAnnotationVal = \"Foo\", " 1.216 -// + "getAnnotationsVals = {" 1.217 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.218 -// + //override every annotation on superClass 1.219 -// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, " 1.220 -// + // ignores inherited annotations 1.221 -// "getDeclAnnoVal = \"NULL\","// ignores inherited 1.222 -// + "getAnnosArgs = {\"Foo\", \"Foo\"}, " 1.223 -// + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})", 1.224 -// "@ExpectedContainer(value=FooContainer.class, " 1.225 -// + "getAnnotationVal = \"FooContainer\", " 1.226 -// + "getAnnotationsVals = {" 1.227 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.228 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, " 1.229 -// + // ignores inherited annotations 1.230 -// "getDeclAnnoVal = \"FooContainer\", "// ignores inherited 1.231 -// + "getAnnosArgs = {\"FooContainer\"}, " 1.232 -// + "getDeclAnnosArgs = {\"FooContainer\"})") { 1.233 + @Override 1.234 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.235 + String className) { 1.236 + String anno = ""; 1.237 + String replaceVal = ""; 1.238 + String contents = ""; 1.239 + JavaFileObject srcFileObj = null; 1.240 + Iterable<? extends JavaFileObject> files = null; 1.241 1.242 -// @Override 1.243 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.244 -// String className) { 1.245 -// String anno = ""; 1.246 -// String replaceVal = ""; 1.247 -// String contents = ""; 1.248 -// JavaFileObject srcFileObj = null; 1.249 -// Iterable<? extends JavaFileObject> files = null; 1.250 + String expectedVals = "\n" + getExpectedBase() + "\n" 1.251 + + getExpectedContainer() + "\n"; 1.252 + StringBuilder commonStmts = getCommonStmts(true); 1.253 1.254 -// String expectedVals = "\n" + getExpectedBase() + "\n" 1.255 -// + getExpectedContainer() + "\n"; 1.256 -// StringBuilder commonStmts = getCommonStmts(true); 1.257 + /* 1.258 + Sample testSrc: 1.259 + @Retention(RetentionPolicy.RUNTIME) 1.260 + @Inherited 1.261 + @Repeatable(FooContainer.class) 1.262 + @interface Foo {int value() default Integer.MAX_VALUE;} 1.263 1.264 -// /* 1.265 -// Sample testSrc: 1.266 -// @Retention(RetentionPolicy.RUNTIME) 1.267 -// @Inherited 1.268 -// @Repeatable(FooContainer.class) 1.269 -// @interface Foo {int value() default Integer.MAX_VALUE;} 1.270 + @Retention(RetentionPolicy.RUNTIME) 1.271 + @Inherited 1.272 + @interface FooContainer { 1.273 + Foo[] value(); 1.274 + } 1.275 1.276 -// @Retention(RetentionPolicy.RUNTIME) 1.277 -// @Inherited 1.278 -// @interface FooContainer { 1.279 -// Foo[] value(); 1.280 -// } 1.281 + @Foo(0) 1.282 + class SuperClass { } 1.283 1.284 -// @Foo() 1.285 -// class SuperClass { } 1.286 + @ExpectedBase 1.287 + @ExpectedContainer 1.288 + @Foo(1) @Foo(2) 1.289 + class SubClass extends SuperClass { } 1.290 + */ 1.291 + //@Inherited only works for classes, no switch cases for method, field, package 1.292 + if (srcType == SrcType.CLASS) { 1.293 + //Contents for SuperClass 1.294 + anno = Helper.ContentVars.BASEANNO.getVal(); 1.295 + replaceVal = commonStmts + "\n" + anno; 1.296 + String superClassContents = srcType.getTemplate() 1.297 + .replace("#CN", SUPERCLASS) 1.298 + .replace("#REPLACE", replaceVal); 1.299 1.300 -// @ExpectedBase 1.301 -// @ExpectedContainer 1.302 -// @Foo @Foo 1.303 -// class SubClass extends SuperClass { } 1.304 -// */ 1.305 + //Contents for SubClass that extends SuperClass 1.306 + anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1.307 + replaceVal = expectedVals + "\n" + anno; 1.308 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.309 + .replace("#CN", className) 1.310 + .replace("#SN", SUPERCLASS) 1.311 + .replace("#REPLACE", replaceVal); 1.312 1.313 -// //@Inherited only works for classes, no switch cases for method, field, package 1.314 -// if (srcType == SrcType.CLASS) { 1.315 -// //Contents for SuperClass 1.316 -// anno = "@Foo(0)"; 1.317 -// replaceVal = commonStmts + "\n" + anno; 1.318 -// String superClassContents = srcType.getTemplate() 1.319 -// .replace("#CN", SUPERCLASS) 1.320 -// .replace("#REPLACE", replaceVal); 1.321 + contents = superClassContents + subClassContents; 1.322 + srcFileObj = Helper.getFile(className, contents); 1.323 + files = Arrays.asList(srcFileObj); 1.324 + } 1.325 + return files; 1.326 + } 1.327 + }, 1.328 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1.329 + // fail with ordering issues 1.330 + ContainerOnSuperSingleOnSub_Inherited( 1.331 + "@ExpectedBase(value=Foo.class, " 1.332 + + "getAnnotationVal = \"@Foo(value=0)\", " 1.333 + + "getAnnotationsVals = {" 1.334 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.335 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1.336 + + "getDeclAnnoVal = \"@Foo(value=0)\"," 1.337 + + "getAnnosArgs = {\"@Foo(value=0)\"}," 1.338 + + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 1.339 + "@ExpectedContainer(value=FooContainer.class, " 1.340 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1.341 + + "getAnnotationsVals = {" 1.342 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.343 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1.344 + + "getDeclAnnoVal = \"NULL\"," 1.345 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1.346 + + "getDeclAnnosArgs = {})") { 1.347 1.348 -// //Contents for SubClass that extends SuperClass 1.349 -// anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 1.350 -// replaceVal = expectedVals + "\n" + anno; 1.351 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.352 -// .replace("#CN", className) 1.353 -// .replace("#SN", SUPERCLASS) 1.354 -// .replace("#REPLACE", replaceVal); 1.355 + @Override 1.356 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.357 + String className) { 1.358 + String anno = ""; 1.359 + String replaceVal = ""; 1.360 + String contents = ""; 1.361 + JavaFileObject srcFileObj = null; 1.362 + Iterable<? extends JavaFileObject> files = null; 1.363 1.364 -// contents = superClassContents + subClassContents; 1.365 -// srcFileObj = Helper.getFile(className, contents); 1.366 -// files = Arrays.asList(srcFileObj); 1.367 -// } 1.368 -// return files; 1.369 -// } 1.370 -// }, 1.371 -// //Testcase not working as expected, JDK-8004912 1.372 -// ContainerOnSuperSingleOnSub_Inherited( 1.373 -// "@ExpectedBase(value=Foo.class, " 1.374 -// + "getAnnotationVal = \"Foo\", " 1.375 -// + "getAnnotationsVals = {" 1.376 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.377 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 1.378 -// + "getDeclAnnoVal = \"Foo\"," 1.379 -// + "getAnnosArgs = {\"Foo\"}," 1.380 -// + "getDeclAnnosArgs = {\"Foo\"})", 1.381 -// "@ExpectedContainer(value=FooContainer.class, " 1.382 -// + "getAnnotationVal = \"FooContainer\", " 1.383 -// + "getAnnotationsVals = {" 1.384 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.385 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 1.386 -// + "getDeclAnnoVal = \"NULL\"," 1.387 -// + "getAnnosArgs = {\"FooContainer\"}," 1.388 -// + "getDeclAnnosArgs = {})") { 1.389 + String expectedVals = "\n" + getExpectedBase() + "\n" 1.390 + + getExpectedContainer() + "\n"; 1.391 + StringBuilder commonStmts = getCommonStmts(true); 1.392 1.393 -// @Override 1.394 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.395 -// String className) { 1.396 -// String anno = ""; 1.397 -// String replaceVal = ""; 1.398 -// String contents = ""; 1.399 -// JavaFileObject srcFileObj = null; 1.400 -// Iterable<? extends JavaFileObject> files = null; 1.401 + /* 1.402 + Sample testSrc: 1.403 + @Retention(RetentionPolicy.RUNTIME) 1.404 + @Inherited 1.405 + @Repeatable(FooContainer.class) 1.406 + @interface Foo {int value() default Integer.MAX_VALUE;} 1.407 1.408 -// String expectedVals = "\n" + getExpectedBase() + "\n" 1.409 -// + getExpectedContainer() + "\n"; 1.410 -// StringBuilder commonStmts = getCommonStmts(true); 1.411 + @Retention(RetentionPolicy.RUNTIME) 1.412 + @Inherited 1.413 + @interface FooContainer { 1.414 + Foo[] value(); 1.415 + } 1.416 1.417 -// /* 1.418 -// Sample testSrc: 1.419 -// @Retention(RetentionPolicy.RUNTIME) 1.420 -// @Inherited 1.421 -// @Repeatable(FooContainer.class) 1.422 -// @interface Foo {int value() default Integer.MAX_VALUE;} 1.423 + @FooContainer(value = {@Foo(1), @Foo(2)}) 1.424 + class SuperClass { } 1.425 1.426 -// @Retention(RetentionPolicy.RUNTIME) 1.427 -// @Inherited 1.428 -// @interface FooContainer { 1.429 -// Foo[] value(); 1.430 -// } 1.431 + @ExpectedBase 1.432 + @ExpectedContainer 1.433 + @Foo(0) 1.434 + class SubClass extends SuperClass { } 1.435 + */ 1.436 + //@Inherited only works for classes, no switch cases for method, field, package 1.437 + if (srcType == SrcType.CLASS) { 1.438 + //Contents for SuperClass 1.439 + anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1.440 + replaceVal = commonStmts + "\n" + anno; 1.441 + String superClassContents = srcType.getTemplate() 1.442 + .replace("#CN", SUPERCLASS) 1.443 + .replace("#REPLACE", replaceVal); 1.444 1.445 -// @FooContainer(value = {@Foo, @Foo}) 1.446 -// class SuperClass { } 1.447 + //Contents for SubClass that extends SuperClass 1.448 + anno = Helper.ContentVars.BASEANNO.getVal(); 1.449 + replaceVal = expectedVals + "\n" + anno; 1.450 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.451 + .replace("#CN", className) 1.452 + .replace("#SN", SUPERCLASS) 1.453 + .replace("#REPLACE", replaceVal); 1.454 1.455 -// @ExpectedBase 1.456 -// @ExpectedContainer 1.457 -// @Foo 1.458 -// class SubClass extends SuperClass { } 1.459 -// */ 1.460 + contents = superClassContents + subClassContents; 1.461 + srcFileObj = Helper.getFile(className, contents); 1.462 + files = Arrays.asList(srcFileObj); 1.463 + } 1.464 + return files; 1.465 + } 1.466 + }, 1.467 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1.468 + // fail with ordering issues 1.469 + SingleOnSuperContainerOnSub_Inherited( 1.470 + "@ExpectedBase(value=Foo.class, " 1.471 + + "getAnnotationVal = \"@Foo(value=0)\", " 1.472 + + "getAnnotationsVals = {" 1.473 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.474 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1.475 + + "getDeclAnnoVal = \"NULL\"," 1.476 + + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 1.477 + + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 1.478 + "@ExpectedContainer(value=FooContainer.class, " 1.479 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1.480 + + "getAnnotationsVals = {" 1.481 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.482 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1.483 + + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 1.484 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1.485 + + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 1.486 1.487 -// //@Inherited only works for classes, no switch cases for method, field, package 1.488 -// if (srcType == SrcType.CLASS) { 1.489 -// //Contents for SuperClass 1.490 -// anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1.491 -// replaceVal = commonStmts + "\n" + anno; 1.492 -// String superClassContents = srcType.getTemplate() 1.493 -// .replace("#CN", SUPERCLASS) 1.494 -// .replace("#REPLACE", replaceVal); 1.495 + @Override 1.496 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.497 + String className) { 1.498 + String anno = ""; 1.499 + String replaceVal = ""; 1.500 + String contents = ""; 1.501 + JavaFileObject srcFileObj = null; 1.502 + Iterable<? extends JavaFileObject> files = null; 1.503 1.504 -// //Contents for SubClass that extends SuperClass 1.505 -// anno = "@Foo(0)"; 1.506 -// replaceVal = expectedVals + "\n" + anno; 1.507 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.508 -// .replace("#CN", className) 1.509 -// .replace("#SN", SUPERCLASS) 1.510 -// .replace("#REPLACE", replaceVal); 1.511 + String expectedVals = "\n" + getExpectedBase() + "\n" 1.512 + + getExpectedContainer() + "\n"; 1.513 + StringBuilder commonStmts = getCommonStmts(true); 1.514 1.515 -// contents = superClassContents + subClassContents; 1.516 -// srcFileObj = Helper.getFile(className, contents); 1.517 -// files = Arrays.asList(srcFileObj); 1.518 -// } 1.519 -// return files; 1.520 -// } 1.521 -// }, 1.522 -// // TestCase not working as expected, JDK-8004912 1.523 -// SingleOnSuperContainerOnSub_Inherited( 1.524 -// "@ExpectedBase(value=Foo.class, " 1.525 -// + "getAnnotationVal = \"Foo\", " 1.526 -// + "getAnnotationsVals = {" 1.527 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.528 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}," 1.529 -// + "getDeclAnnoVal = \"NULL\"," 1.530 -// + "getAnnosArgs = {\"Foo\", \"Foo\"}," 1.531 -// + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})", 1.532 -// "@ExpectedContainer(value=FooContainer.class, " 1.533 -// + "getAnnotationVal = \"FooContainer\", " 1.534 -// + "getAnnotationsVals = {" 1.535 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.536 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}," 1.537 -// + "getDeclAnnoVal = \"FooContainer\"," 1.538 -// + "getAnnosArgs = {\"FooContainer\"}," 1.539 -// + "getDeclAnnosArgs = {\"FooContainer\"})") { 1.540 + /* 1.541 + Sample testSrc: 1.542 + @Retention(RetentionPolicy.RUNTIME) 1.543 + @Inherited 1.544 + @Repeatable(FooContainer.class) 1.545 + @interface Foo {int value() default Integer.MAX_VALUE;} 1.546 1.547 -// @Override 1.548 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.549 -// String className) { 1.550 -// String anno = ""; 1.551 -// String replaceVal = ""; 1.552 -// String contents = ""; 1.553 -// JavaFileObject srcFileObj = null; 1.554 -// Iterable<? extends JavaFileObject> files = null; 1.555 + @Retention(RetentionPolicy.RUNTIME) 1.556 + @Inherited 1.557 + @interface FooContainer { 1.558 + Foo[] value(); 1.559 + } 1.560 1.561 -// String expectedVals = "\n" + getExpectedBase() + "\n" 1.562 -// + getExpectedContainer() + "\n"; 1.563 -// StringBuilder commonStmts = getCommonStmts(true); 1.564 + @Foo(0) 1.565 + class SuperClass { } 1.566 1.567 -// /* 1.568 -// Sample testSrc: 1.569 -// @Retention(RetentionPolicy.RUNTIME) 1.570 -// @Inherited 1.571 -// @Repeatable(FooContainer.class) 1.572 -// @interface Foo {int value() default Integer.MAX_VALUE;} 1.573 + @ExpectedBase 1.574 + @ExpectedContainer 1.575 + @FooContainer(value = {@Foo(1), @Foo(2)}) 1.576 + class SubClass extends SuperClass { } 1.577 + */ 1.578 + //@Inherited only works for classes, no switch cases for method, field, package 1.579 + if (srcType == SrcType.CLASS) { 1.580 + //Contents for SuperClass 1.581 + anno = Helper.ContentVars.BASEANNO.getVal(); 1.582 + replaceVal = commonStmts + "\n" + anno; 1.583 + String superClassContents = srcType.getTemplate() 1.584 + .replace("#CN", SUPERCLASS) 1.585 + .replace("#REPLACE", replaceVal); 1.586 1.587 -// @Retention(RetentionPolicy.RUNTIME) 1.588 -// @Inherited 1.589 -// @interface FooContainer { 1.590 -// Foo[] value(); 1.591 -// } 1.592 + //Contents for SubClass that extends SuperClass 1.593 + anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1.594 + replaceVal = expectedVals + "\n" + anno; 1.595 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.596 + .replace("#CN", className) 1.597 + .replace("#SN", SUPERCLASS) 1.598 + .replace("#REPLACE", replaceVal); 1.599 1.600 -// @Foo 1.601 -// class SuperClass { } 1.602 - 1.603 -// @ExpectedBase 1.604 -// @ExpectedContainer 1.605 -// @FooContainer(value = {@Foo, @Foo}) 1.606 -// class SubClass extends SuperClass { } 1.607 -// */ 1.608 - 1.609 -// //@Inherited only works for classes, no switch cases for method, field, package 1.610 -// if (srcType == SrcType.CLASS) { 1.611 -// //Contents for SuperClass 1.612 -// anno = "@Foo(0)"; 1.613 -// replaceVal = commonStmts + "\n" + anno; 1.614 -// String superClassContents = srcType.getTemplate() 1.615 -// .replace("#CN", SUPERCLASS) 1.616 -// .replace("#REPLACE", replaceVal); 1.617 - 1.618 -// //Contents for SubClass that extends SuperClass 1.619 -// anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 1.620 -// replaceVal = expectedVals + "\n" + anno; 1.621 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.622 -// .replace("#CN", className) 1.623 -// .replace("#SN", SUPERCLASS) 1.624 -// .replace("#REPLACE", replaceVal); 1.625 - 1.626 -// contents = superClassContents + subClassContents; 1.627 -// srcFileObj = Helper.getFile(className, contents); 1.628 -// files = Arrays.asList(srcFileObj); 1.629 -// } 1.630 -// return files; 1.631 -// } 1.632 -// }, 1.633 + contents = superClassContents + subClassContents; 1.634 + srcFileObj = Helper.getFile(className, contents); 1.635 + files = Arrays.asList(srcFileObj); 1.636 + } 1.637 + return files; 1.638 + } 1.639 + }, 1.640 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1.641 // fail with ordering issues 1.642 SingleOnSuperContainerAndSingleOnSub_Inherited( 1.643 @@ -2009,87 +2014,88 @@ 1.644 return files; 1.645 } 1.646 }, 1.647 -// // TestCase not working as expected, JDK-8004912 1.648 -// ContainerAndSingleOnSuperSingleOnSub_Inherited( 1.649 -// "@ExpectedBase(value=Foo.class, " 1.650 -// + "getAnnotationVal = \"Foo\", " 1.651 -// + "getAnnotationsVals = {" 1.652 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.653 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 1.654 -// + "getDeclAnnoVal = \"Foo\"," 1.655 -// + "getAnnosArgs = {\"Foo\"}," 1.656 -// + "getDeclAnnosArgs = {\"Foo\"})", 1.657 -// "@ExpectedContainer(value=FooContainer.class, " 1.658 -// + "getAnnotationVal = \"FooContainer\", " 1.659 -// + "getAnnotationsVals = {" 1.660 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 1.661 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 1.662 -// + "getDeclAnnoVal = \"NULL\"," 1.663 -// + "getAnnosArgs = {\"FooContainer\"}," 1.664 -// + "getDeclAnnosArgs = {})") { 1.665 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 1.666 + // fail with ordering issues 1.667 + ContainerAndSingleOnSuperSingleOnSub_Inherited( 1.668 + "@ExpectedBase(value=Foo.class, " 1.669 + + "getAnnotationVal = \"@Foo(value=0)\", " 1.670 + + "getAnnotationsVals = {" 1.671 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.672 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1.673 + + "getDeclAnnoVal = \"@Foo(value=0)\"," 1.674 + + "getAnnosArgs = {\"@Foo(value=0)\"}," 1.675 + + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 1.676 + "@ExpectedContainer(value=FooContainer.class, " 1.677 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 1.678 + + "getAnnotationsVals = {" 1.679 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 1.680 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 1.681 + + "getDeclAnnoVal = \"NULL\"," 1.682 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 1.683 + + "getDeclAnnosArgs = {})") { 1.684 1.685 -// @Override 1.686 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.687 -// String className) { 1.688 -// String anno = ""; 1.689 -// String replaceVal = ""; 1.690 -// String contents = ""; 1.691 -// JavaFileObject srcFileObj = null; 1.692 -// Iterable<? extends JavaFileObject> files = null; 1.693 + @Override 1.694 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 1.695 + String className) { 1.696 + String anno = ""; 1.697 + String replaceVal = ""; 1.698 + String contents = ""; 1.699 + JavaFileObject srcFileObj = null; 1.700 + Iterable<? extends JavaFileObject> files = null; 1.701 1.702 -// String expectedVals = "\n" + getExpectedBase() + "\n" 1.703 -// + getExpectedContainer() + "\n"; 1.704 -// StringBuilder commonStmts = getCommonStmts(true); 1.705 + String expectedVals = "\n" + getExpectedBase() + "\n" 1.706 + + getExpectedContainer() + "\n"; 1.707 + StringBuilder commonStmts = getCommonStmts(true); 1.708 1.709 -// /* 1.710 -// Sample testSrc: 1.711 -// @Retention(RetentionPolicy.RUNTIME) 1.712 -// @Inherited 1.713 -// @Repeatable(FooContainer.class) 1.714 -// @interface Foo {int value() default Integer.MAX_VALUE;} 1.715 + /* 1.716 + Sample testSrc: 1.717 + @Retention(RetentionPolicy.RUNTIME) 1.718 + @Inherited 1.719 + @Repeatable(FooContainer.class) 1.720 + @interface Foo {int value() default Integer.MAX_VALUE;} 1.721 1.722 -// @Retention(RetentionPolicy.RUNTIME) 1.723 -// @Inherited 1.724 -// @interface FooContainer { 1.725 -// Foo[] value(); 1.726 -// } 1.727 + @Retention(RetentionPolicy.RUNTIME) 1.728 + @Inherited 1.729 + @interface FooContainer { 1.730 + Foo[] value(); 1.731 + } 1.732 1.733 -// @FooContainer(value = {@Foo, @Foo}) 1.734 -// @Foo 1.735 -// class SuperClass { } 1.736 + @FooContainer(value = {@Foo(1), @Foo(2)}) 1.737 + @Foo(3) 1.738 + class SuperClass { } 1.739 1.740 -// @ExpectedBase 1.741 -// @ExpectedContainer 1.742 -// @Foo 1.743 -// class SubClass extends SuperClass { } 1.744 -// */ 1.745 + @ExpectedBase 1.746 + @ExpectedContainer 1.747 + @Foo(0) 1.748 + class SubClass extends SuperClass { } 1.749 + */ 1.750 1.751 -// //@Inherited only works for classes, no switch cases for method, field, package 1.752 -// if (srcType == SrcType.CLASS) { 1.753 -// //Contents for SuperClass 1.754 -// anno = Helper.ContentVars.LEGACYCONTAINER.getVal() 1.755 -// + Helper.ContentVars.BASEANNO.getVal(); 1.756 -// replaceVal = commonStmts + "\n" + anno; 1.757 -// String superClassContents = srcType.getTemplate() 1.758 -// .replace("#CN", SUPERCLASS) 1.759 -// .replace("#REPLACE", replaceVal); 1.760 + //@Inherited only works for classes, no switch cases for method, field, package 1.761 + if (srcType == SrcType.CLASS) { 1.762 + //Contents for SuperClass 1.763 + anno = Helper.ContentVars.LEGACYCONTAINER.getVal() 1.764 + + "@Foo(3)" ; 1.765 + replaceVal = commonStmts + "\n" + anno; 1.766 + String superClassContents = srcType.getTemplate() 1.767 + .replace("#CN", SUPERCLASS) 1.768 + .replace("#REPLACE", replaceVal); 1.769 1.770 -// //Contents for SubClass that extends SuperClass 1.771 -// anno = "@Foo(0)"; 1.772 -// replaceVal = expectedVals + "\n" + anno; 1.773 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.774 -// .replace("#CN", className) 1.775 -// .replace("#SN", SUPERCLASS) 1.776 -// .replace("#REPLACE", replaceVal); 1.777 + //Contents for SubClass that extends SuperClass 1.778 + anno = Helper.ContentVars.BASEANNO.getVal(); 1.779 + replaceVal = expectedVals + "\n" + anno; 1.780 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 1.781 + .replace("#CN", className) 1.782 + .replace("#SN", SUPERCLASS) 1.783 + .replace("#REPLACE", replaceVal); 1.784 1.785 -// contents = superClassContents + subClassContents; 1.786 -// srcFileObj = Helper.getFile(className, contents); 1.787 -// files = Arrays.asList(srcFileObj); 1.788 -// } 1.789 -// return files; 1.790 -// } 1.791 -// } 1.792 - ; 1.793 + contents = superClassContents + subClassContents; 1.794 + srcFileObj = Helper.getFile(className, contents); 1.795 + files = Arrays.asList(srcFileObj); 1.796 + } 1.797 + return files; 1.798 + } 1.799 + }; 1.800 + 1.801 private String expectedBase, expectedContainer; 1.802 1.803 private TestCase(String expectedBase, String expectedContainer) { 1.804 @@ -2942,7 +2948,7 @@ 1.805 System.out.print("Actual Arr Values: "); 1.806 for (Annotation a : actualAnnos) { 1.807 if (a != null && a.annotationType() != null) { 1.808 - System.out.print("[" + a.annotationType().getSimpleName() + "]"); 1.809 + System.out.print("[" + a.toString() + "]"); 1.810 } else { 1.811 System.out.println("[null]"); 1.812 }