8027477: Enable repeating annotations test cases since JDK-8004912 is fixed

Reviewed-by: jjg, jfranck
This commit is contained in:
Matherey Nunez 2014-01-22 12:22:23 -08:00 committed by Sonali Goel
parent bb0c5d0f71
commit 0c38c2d401
2 changed files with 371 additions and 362 deletions

3
langtools/commit.txt Normal file
View file

@ -0,0 +1,3 @@
8027477: Enable repeating annotations test cases since JDK-8004912 is fixed
Reviewed-by: jjg, jfranck
Contributed-by: matherey.nunez@oracle.com

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 8001457 * @bug 8001457 8027477
* @author sogoel * @author sogoel
* @summary Reflection api tests * @summary Reflection api tests
* @build Helper * @build Helper
@ -159,7 +159,12 @@ public class ReflectionTest {
"SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy", "SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy",
"ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy", "ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy",
"SingleAnnoWithContainer", "SingleAnnoWithContainer",
"SingleOnSuperContainerAndSingleOnSub_Inherited"); "SingleOnSuperContainerAndSingleOnSub_Inherited",
"RepeatableOnSuperSingleOnSub_Inherited",
"SingleOnSuperRepeatableOnSub_Inherited",
"ContainerOnSuperSingleOnSub_Inherited",
"SingleOnSuperContainerOnSub_Inherited",
"ContainerAndSingleOnSuperSingleOnSub_Inherited");
if (orderingTestFailures.contains(testCase.toString())) { if (orderingTestFailures.contains(testCase.toString())) {
CHECKORDERING = false; CHECKORDERING = false;
} else } else
@ -1612,323 +1617,323 @@ public class ReflectionTest {
return files; return files;
} }
}, },
// // Testcase not working as expected, JDK-8004912 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
// RepeatableOnSuperSingleOnSub_Inherited( // fail with ordering issues
// "@ExpectedBase(value=Foo.class, " RepeatableOnSuperSingleOnSub_Inherited(
// + "getAnnotationVal = \"Foo\", " "@ExpectedBase(value=Foo.class, "
// + "getAnnotationsVals = {" + "getAnnotationVal = \"@Foo(value=3)\", "
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " + "getAnnotationsVals = {"
// + //override every annotation on superClass + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, " + //override every annotation on superClass
// + // ignores inherited annotations "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, "
// "getDeclAnnoVal = \"Foo\", " // ignores inherited + // ignores inherited annotations
// + "getAnnosArgs = {\"Foo\"}, " "getDeclAnnoVal = \"@Foo(value=3)\", " // ignores inherited
// + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited + "getAnnosArgs = {\"@Foo(value=3)\"}, "
// "@ExpectedContainer(value=FooContainer.class, " + "getDeclAnnosArgs = { \"@Foo(value=3)\" })", // ignores inherited
// + "getAnnotationVal = \"FooContainer\", " "@ExpectedContainer(value=FooContainer.class, "
// + "getAnnotationsVals = {" + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " + "getAnnotationsVals = {"
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, " + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
// + // ignores inherited annotations + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, "
// "getDeclAnnoVal = \"NULL\", " + // ignores inherited annotations
// + "getAnnosArgs = {\"FooContainer\"}, " "getDeclAnnoVal = \"NULL\", "
// + "getDeclAnnosArgs = {}) // ignores inherited ") { + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosArgs = {}) // ignores inherited ") {
// @Override @Override
// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
// String className) { String className) {
// String anno = ""; String anno = "";
// String replaceVal = ""; String replaceVal = "";
// String contents = ""; String contents = "";
// JavaFileObject srcFileObj = null; JavaFileObject srcFileObj = null;
// Iterable<? extends JavaFileObject> files = null; Iterable<? extends JavaFileObject> files = null;
// String expectedVals = "\n" + getExpectedBase() + "\n" String expectedVals = "\n" + getExpectedBase() + "\n"
// + getExpectedContainer() + "\n"; + getExpectedContainer() + "\n";
// StringBuilder commonStmts = getCommonStmts(true); StringBuilder commonStmts = getCommonStmts(true);
// /* /*
// Sample testSrc: Sample testSrc:
// @Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
// @Inherited @Inherited
// @Repeatable(FooContainer.class) @Repeatable(FooContainer.class)
// @interface Foo {int value() default Integer.MAX_VALUE;} @interface Foo {int value() default Integer.MAX_VALUE;}
// @Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
// @Inherited @Inherited
// @interface FooContainer { @interface FooContainer {
// Foo[] value(); Foo[] value();
// } }
// @Foo() @Foo @Foo(1) @Foo(2)
// class SuperClass { } class SuperClass { }
// @ExpectedBase @ExpectedBase
// @ExpectedContainer @ExpectedContainer
// @Foo @Foo(3)
// class SubClass extends SuperClass { } class SubClass extends SuperClass { }
// */ */
// //@Inherited only works for classes, no switch cases for method, field, package //@Inherited only works for classes, no switch cases for method, field, package
if (srcType == SrcType.CLASS) {
//Contents for SuperClass
anno = Helper.ContentVars.REPEATABLEANNO.getVal();
replaceVal = commonStmts + "\n" + anno;
String superClassContents = srcType.getTemplate()
.replace("#CN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// if (srcType == SrcType.CLASS) { //Contents for SubClass that extends SuperClass
// //Contents for SuperClass anno = "@Foo(3)";
// anno = Helper.ContentVars.REPEATABLEANNO.getVal(); replaceVal = expectedVals + "\n" + anno;
// replaceVal = commonStmts + "\n" + anno; String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
// String superClassContents = srcType.getTemplate() .replace("#CN", className)
// .replace("#CN", SUPERCLASS) .replace("#SN", SUPERCLASS)
// .replace("#REPLACE", replaceVal); .replace("#REPLACE", replaceVal);
contents = superClassContents + subClassContents;
srcFileObj = Helper.getFile(className, contents);
files = Arrays.asList(srcFileObj);
}
return files;
}
},
// @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
// fail with ordering issues
SingleOnSuperRepeatableOnSub_Inherited(
"@ExpectedBase(value=Foo.class, "
+ "getAnnotationVal = \"@Foo(value=0)\", "
+ "getAnnotationsVals = {"
+ "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ //override every annotation on superClass
"getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ // ignores inherited annotations
"getDeclAnnoVal = \"NULL\","// ignores inherited
+ "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, "
+ "getDeclAnnosArgs = { \"@Foo(value=1)\", \"@Foo(value=2)\"})",
"@ExpectedContainer(value=FooContainer.class, "
+ "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+ "getAnnotationsVals = {"
+ "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ // ignores inherited annotations
"getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "// ignores inherited
+ "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") {
// //Contents for SubClass that extends SuperClass @Override
// anno = "@Foo(0)"; public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
// replaceVal = expectedVals + "\n" + anno; String className) {
// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() String anno = "";
// .replace("#CN", className) String replaceVal = "";
// .replace("#SN", SUPERCLASS) String contents = "";
// .replace("#REPLACE", replaceVal); JavaFileObject srcFileObj = null;
// contents = superClassContents + subClassContents; Iterable<? extends JavaFileObject> files = null;
// srcFileObj = Helper.getFile(className, contents);
// files = Arrays.asList(srcFileObj);
// }
// return files;
// }
// },
// //Testcase not working as expected, JDK-8004912
// SingleOnSuperRepeatableOnSub_Inherited(
// "@ExpectedBase(value=Foo.class, "
// + "getAnnotationVal = \"Foo\", "
// + "getAnnotationsVals = {"
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
// + //override every annotation on superClass
// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
// + // ignores inherited annotations
// "getDeclAnnoVal = \"NULL\","// ignores inherited
// + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
// + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})",
// "@ExpectedContainer(value=FooContainer.class, "
// + "getAnnotationVal = \"FooContainer\", "
// + "getAnnotationsVals = {"
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
// + // ignores inherited annotations
// "getDeclAnnoVal = \"FooContainer\", "// ignores inherited
// + "getAnnosArgs = {\"FooContainer\"}, "
// + "getDeclAnnosArgs = {\"FooContainer\"})") {
// @Override String expectedVals = "\n" + getExpectedBase() + "\n"
// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, + getExpectedContainer() + "\n";
// String className) { StringBuilder commonStmts = getCommonStmts(true);
// String anno = "";
// String replaceVal = "";
// String contents = "";
// JavaFileObject srcFileObj = null;
// Iterable<? extends JavaFileObject> files = null;
// String expectedVals = "\n" + getExpectedBase() + "\n" /*
// + getExpectedContainer() + "\n"; Sample testSrc:
// StringBuilder commonStmts = getCommonStmts(true); @Retention(RetentionPolicy.RUNTIME)
@Inherited
@Repeatable(FooContainer.class)
@interface Foo {int value() default Integer.MAX_VALUE;}
// /* @Retention(RetentionPolicy.RUNTIME)
// Sample testSrc: @Inherited
// @Retention(RetentionPolicy.RUNTIME) @interface FooContainer {
// @Inherited Foo[] value();
// @Repeatable(FooContainer.class) }
// @interface Foo {int value() default Integer.MAX_VALUE;}
// @Retention(RetentionPolicy.RUNTIME) @Foo(0)
// @Inherited class SuperClass { }
// @interface FooContainer {
// Foo[] value();
// }
// @Foo() @ExpectedBase
// class SuperClass { } @ExpectedContainer
@Foo(1) @Foo(2)
class SubClass extends SuperClass { }
*/
//@Inherited only works for classes, no switch cases for method, field, package
if (srcType == SrcType.CLASS) {
//Contents for SuperClass
anno = Helper.ContentVars.BASEANNO.getVal();
replaceVal = commonStmts + "\n" + anno;
String superClassContents = srcType.getTemplate()
.replace("#CN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// @ExpectedBase //Contents for SubClass that extends SuperClass
// @ExpectedContainer anno = Helper.ContentVars.REPEATABLEANNO.getVal();
// @Foo @Foo replaceVal = expectedVals + "\n" + anno;
// class SubClass extends SuperClass { } String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
// */ .replace("#CN", className)
.replace("#SN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// //@Inherited only works for classes, no switch cases for method, field, package contents = superClassContents + subClassContents;
// if (srcType == SrcType.CLASS) { srcFileObj = Helper.getFile(className, contents);
// //Contents for SuperClass files = Arrays.asList(srcFileObj);
// anno = "@Foo(0)"; }
// replaceVal = commonStmts + "\n" + anno; return files;
// String superClassContents = srcType.getTemplate() }
// .replace("#CN", SUPERCLASS) },
// .replace("#REPLACE", replaceVal); // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
// fail with ordering issues
ContainerOnSuperSingleOnSub_Inherited(
"@ExpectedBase(value=Foo.class, "
+ "getAnnotationVal = \"@Foo(value=0)\", "
+ "getAnnotationsVals = {"
+ "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
+ "getDeclAnnoVal = \"@Foo(value=0)\","
+ "getAnnosArgs = {\"@Foo(value=0)\"},"
+ "getDeclAnnosArgs = {\"@Foo(value=0)\"})",
"@ExpectedContainer(value=FooContainer.class, "
+ "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+ "getAnnotationsVals = {"
+ "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
+ "getDeclAnnoVal = \"NULL\","
+ "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+ "getDeclAnnosArgs = {})") {
// //Contents for SubClass that extends SuperClass @Override
// anno = Helper.ContentVars.REPEATABLEANNO.getVal(); public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
// replaceVal = expectedVals + "\n" + anno; String className) {
// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() String anno = "";
// .replace("#CN", className) String replaceVal = "";
// .replace("#SN", SUPERCLASS) String contents = "";
// .replace("#REPLACE", replaceVal); JavaFileObject srcFileObj = null;
Iterable<? extends JavaFileObject> files = null;
// contents = superClassContents + subClassContents; String expectedVals = "\n" + getExpectedBase() + "\n"
// srcFileObj = Helper.getFile(className, contents); + getExpectedContainer() + "\n";
// files = Arrays.asList(srcFileObj); StringBuilder commonStmts = getCommonStmts(true);
// }
// return files;
// }
// },
// //Testcase not working as expected, JDK-8004912
// ContainerOnSuperSingleOnSub_Inherited(
// "@ExpectedBase(value=Foo.class, "
// + "getAnnotationVal = \"Foo\", "
// + "getAnnotationsVals = {"
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
// + "getDeclAnnoVal = \"Foo\","
// + "getAnnosArgs = {\"Foo\"},"
// + "getDeclAnnosArgs = {\"Foo\"})",
// "@ExpectedContainer(value=FooContainer.class, "
// + "getAnnotationVal = \"FooContainer\", "
// + "getAnnotationsVals = {"
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
// + "getDeclAnnoVal = \"NULL\","
// + "getAnnosArgs = {\"FooContainer\"},"
// + "getDeclAnnosArgs = {})") {
// @Override /*
// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, Sample testSrc:
// String className) { @Retention(RetentionPolicy.RUNTIME)
// String anno = ""; @Inherited
// String replaceVal = ""; @Repeatable(FooContainer.class)
// String contents = ""; @interface Foo {int value() default Integer.MAX_VALUE;}
// JavaFileObject srcFileObj = null;
// Iterable<? extends JavaFileObject> files = null;
// String expectedVals = "\n" + getExpectedBase() + "\n" @Retention(RetentionPolicy.RUNTIME)
// + getExpectedContainer() + "\n"; @Inherited
// StringBuilder commonStmts = getCommonStmts(true); @interface FooContainer {
Foo[] value();
}
// /* @FooContainer(value = {@Foo(1), @Foo(2)})
// Sample testSrc: class SuperClass { }
// @Retention(RetentionPolicy.RUNTIME)
// @Inherited
// @Repeatable(FooContainer.class)
// @interface Foo {int value() default Integer.MAX_VALUE;}
// @Retention(RetentionPolicy.RUNTIME) @ExpectedBase
// @Inherited @ExpectedContainer
// @interface FooContainer { @Foo(0)
// Foo[] value(); class SubClass extends SuperClass { }
// } */
//@Inherited only works for classes, no switch cases for method, field, package
if (srcType == SrcType.CLASS) {
//Contents for SuperClass
anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
replaceVal = commonStmts + "\n" + anno;
String superClassContents = srcType.getTemplate()
.replace("#CN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// @FooContainer(value = {@Foo, @Foo}) //Contents for SubClass that extends SuperClass
// class SuperClass { } anno = Helper.ContentVars.BASEANNO.getVal();
replaceVal = expectedVals + "\n" + anno;
String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
.replace("#CN", className)
.replace("#SN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// @ExpectedBase contents = superClassContents + subClassContents;
// @ExpectedContainer srcFileObj = Helper.getFile(className, contents);
// @Foo files = Arrays.asList(srcFileObj);
// class SubClass extends SuperClass { } }
// */ return files;
}
},
// @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
// fail with ordering issues
SingleOnSuperContainerOnSub_Inherited(
"@ExpectedBase(value=Foo.class, "
+ "getAnnotationVal = \"@Foo(value=0)\", "
+ "getAnnotationsVals = {"
+ "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+ "getDeclAnnoVal = \"NULL\","
+ "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"},"
+ "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})",
"@ExpectedContainer(value=FooContainer.class, "
+ "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
+ "getAnnotationsVals = {"
+ "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
+ "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+ "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\","
+ "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+ "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") {
// //@Inherited only works for classes, no switch cases for method, field, package @Override
// if (srcType == SrcType.CLASS) { public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
// //Contents for SuperClass String className) {
// anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); String anno = "";
// replaceVal = commonStmts + "\n" + anno; String replaceVal = "";
// String superClassContents = srcType.getTemplate() String contents = "";
// .replace("#CN", SUPERCLASS) JavaFileObject srcFileObj = null;
// .replace("#REPLACE", replaceVal); Iterable<? extends JavaFileObject> files = null;
// //Contents for SubClass that extends SuperClass String expectedVals = "\n" + getExpectedBase() + "\n"
// anno = "@Foo(0)"; + getExpectedContainer() + "\n";
// replaceVal = expectedVals + "\n" + anno; StringBuilder commonStmts = getCommonStmts(true);
// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
// .replace("#CN", className)
// .replace("#SN", SUPERCLASS)
// .replace("#REPLACE", replaceVal);
// contents = superClassContents + subClassContents; /*
// srcFileObj = Helper.getFile(className, contents); Sample testSrc:
// files = Arrays.asList(srcFileObj); @Retention(RetentionPolicy.RUNTIME)
// } @Inherited
// return files; @Repeatable(FooContainer.class)
// } @interface Foo {int value() default Integer.MAX_VALUE;}
// },
// // TestCase not working as expected, JDK-8004912
// SingleOnSuperContainerOnSub_Inherited(
// "@ExpectedBase(value=Foo.class, "
// + "getAnnotationVal = \"Foo\", "
// + "getAnnotationsVals = {"
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
// + "getDeclAnnoVal = \"NULL\","
// + "getAnnosArgs = {\"Foo\", \"Foo\"},"
// + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
// "@ExpectedContainer(value=FooContainer.class, "
// + "getAnnotationVal = \"FooContainer\", "
// + "getAnnotationsVals = {"
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
// + "getDeclAnnoVal = \"FooContainer\","
// + "getAnnosArgs = {\"FooContainer\"},"
// + "getDeclAnnosArgs = {\"FooContainer\"})") {
// @Override @Retention(RetentionPolicy.RUNTIME)
// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, @Inherited
// String className) { @interface FooContainer {
// String anno = ""; Foo[] value();
// String replaceVal = ""; }
// String contents = "";
// JavaFileObject srcFileObj = null;
// Iterable<? extends JavaFileObject> files = null;
// String expectedVals = "\n" + getExpectedBase() + "\n" @Foo(0)
// + getExpectedContainer() + "\n"; class SuperClass { }
// StringBuilder commonStmts = getCommonStmts(true);
// /* @ExpectedBase
// Sample testSrc: @ExpectedContainer
// @Retention(RetentionPolicy.RUNTIME) @FooContainer(value = {@Foo(1), @Foo(2)})
// @Inherited class SubClass extends SuperClass { }
// @Repeatable(FooContainer.class) */
// @interface Foo {int value() default Integer.MAX_VALUE;} //@Inherited only works for classes, no switch cases for method, field, package
if (srcType == SrcType.CLASS) {
//Contents for SuperClass
anno = Helper.ContentVars.BASEANNO.getVal();
replaceVal = commonStmts + "\n" + anno;
String superClassContents = srcType.getTemplate()
.replace("#CN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// @Retention(RetentionPolicy.RUNTIME) //Contents for SubClass that extends SuperClass
// @Inherited anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
// @interface FooContainer { replaceVal = expectedVals + "\n" + anno;
// Foo[] value(); String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
// } .replace("#CN", className)
.replace("#SN", SUPERCLASS)
.replace("#REPLACE", replaceVal);
// @Foo contents = superClassContents + subClassContents;
// class SuperClass { } srcFileObj = Helper.getFile(className, contents);
files = Arrays.asList(srcFileObj);
// @ExpectedBase }
// @ExpectedContainer return files;
// @FooContainer(value = {@Foo, @Foo}) }
// class SubClass extends SuperClass { } },
// */
// //@Inherited only works for classes, no switch cases for method, field, package
// if (srcType == SrcType.CLASS) {
// //Contents for SuperClass
// anno = "@Foo(0)";
// replaceVal = commonStmts + "\n" + anno;
// String superClassContents = srcType.getTemplate()
// .replace("#CN", SUPERCLASS)
// .replace("#REPLACE", replaceVal);
// //Contents for SubClass that extends SuperClass
// anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
// replaceVal = expectedVals + "\n" + anno;
// String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
// .replace("#CN", className)
// .replace("#SN", SUPERCLASS)
// .replace("#REPLACE", replaceVal);
// contents = superClassContents + subClassContents;
// srcFileObj = Helper.getFile(className, contents);
// files = Arrays.asList(srcFileObj);
// }
// return files;
// }
// },
// @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
// fail with ordering issues // fail with ordering issues
SingleOnSuperContainerAndSingleOnSub_Inherited( SingleOnSuperContainerAndSingleOnSub_Inherited(
@ -2009,87 +2014,88 @@ public class ReflectionTest {
return files; return files;
} }
}, },
// // TestCase not working as expected, JDK-8004912 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest
// ContainerAndSingleOnSuperSingleOnSub_Inherited( // fail with ordering issues
// "@ExpectedBase(value=Foo.class, " ContainerAndSingleOnSuperSingleOnSub_Inherited(
// + "getAnnotationVal = \"Foo\", " "@ExpectedBase(value=Foo.class, "
// + "getAnnotationsVals = {" + "getAnnotationVal = \"@Foo(value=0)\", "
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " + "getAnnotationsVals = {"
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
// + "getDeclAnnoVal = \"Foo\"," + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
// + "getAnnosArgs = {\"Foo\"}," + "getDeclAnnoVal = \"@Foo(value=0)\","
// + "getDeclAnnosArgs = {\"Foo\"})", + "getAnnosArgs = {\"@Foo(value=0)\"},"
// "@ExpectedContainer(value=FooContainer.class, " + "getDeclAnnosArgs = {\"@Foo(value=0)\"})",
// + "getAnnotationVal = \"FooContainer\", " "@ExpectedContainer(value=FooContainer.class, "
// + "getAnnotationsVals = {" + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "
// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " + "getAnnotationsVals = {"
// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, "
// + "getDeclAnnoVal = \"NULL\"," + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"},"
// + "getAnnosArgs = {\"FooContainer\"}," + "getDeclAnnoVal = \"NULL\","
// + "getDeclAnnosArgs = {})") { + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"},"
+ "getDeclAnnosArgs = {})") {
// @Override @Override
// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
// String className) { String className) {
// String anno = ""; String anno = "";
// String replaceVal = ""; String replaceVal = "";
// String contents = ""; String contents = "";
// JavaFileObject srcFileObj = null; JavaFileObject srcFileObj = null;
// Iterable<? extends JavaFileObject> files = null; Iterable<? extends JavaFileObject> files = null;
// String expectedVals = "\n" + getExpectedBase() + "\n" String expectedVals = "\n" + getExpectedBase() + "\n"
// + getExpectedContainer() + "\n"; + getExpectedContainer() + "\n";
// StringBuilder commonStmts = getCommonStmts(true); StringBuilder commonStmts = getCommonStmts(true);
// /* /*
// Sample testSrc: Sample testSrc:
// @Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
// @Inherited @Inherited
// @Repeatable(FooContainer.class) @Repeatable(FooContainer.class)
// @interface Foo {int value() default Integer.MAX_VALUE;} @interface Foo {int value() default Integer.MAX_VALUE;}
// @Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
// @Inherited @Inherited
// @interface FooContainer { @interface FooContainer {
// Foo[] value(); Foo[] value();
// } }
// @FooContainer(value = {@Foo, @Foo}) @FooContainer(value = {@Foo(1), @Foo(2)})
// @Foo @Foo(3)
// class SuperClass { } class SuperClass { }
// @ExpectedBase @ExpectedBase
// @ExpectedContainer @ExpectedContainer
// @Foo @Foo(0)
// class SubClass extends SuperClass { } class SubClass extends SuperClass { }
// */ */
// //@Inherited only works for classes, no switch cases for method, field, package //@Inherited only works for classes, no switch cases for method, field, package
// if (srcType == SrcType.CLASS) { if (srcType == SrcType.CLASS) {
// //Contents for SuperClass //Contents for SuperClass
// anno = Helper.ContentVars.LEGACYCONTAINER.getVal() anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
// + Helper.ContentVars.BASEANNO.getVal(); + "@Foo(3)" ;
// replaceVal = commonStmts + "\n" + anno; replaceVal = commonStmts + "\n" + anno;
// String superClassContents = srcType.getTemplate() String superClassContents = srcType.getTemplate()
// .replace("#CN", SUPERCLASS) .replace("#CN", SUPERCLASS)
// .replace("#REPLACE", replaceVal); .replace("#REPLACE", replaceVal);
// //Contents for SubClass that extends SuperClass //Contents for SubClass that extends SuperClass
// anno = "@Foo(0)"; anno = Helper.ContentVars.BASEANNO.getVal();
// replaceVal = expectedVals + "\n" + anno; replaceVal = expectedVals + "\n" + anno;
// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
// .replace("#CN", className) .replace("#CN", className)
// .replace("#SN", SUPERCLASS) .replace("#SN", SUPERCLASS)
// .replace("#REPLACE", replaceVal); .replace("#REPLACE", replaceVal);
contents = superClassContents + subClassContents;
srcFileObj = Helper.getFile(className, contents);
files = Arrays.asList(srcFileObj);
}
return files;
}
};
// contents = superClassContents + subClassContents;
// srcFileObj = Helper.getFile(className, contents);
// files = Arrays.asList(srcFileObj);
// }
// return files;
// }
// }
;
private String expectedBase, expectedContainer; private String expectedBase, expectedContainer;
private TestCase(String expectedBase, String expectedContainer) { private TestCase(String expectedBase, String expectedContainer) {
@ -2942,7 +2948,7 @@ public class ReflectionTest {
System.out.print("Actual Arr Values: "); System.out.print("Actual Arr Values: ");
for (Annotation a : actualAnnos) { for (Annotation a : actualAnnos) {
if (a != null && a.annotationType() != null) { if (a != null && a.annotationType() != null) {
System.out.print("[" + a.annotationType().getSimpleName() + "]"); System.out.print("[" + a.toString() + "]");
} else { } else {
System.out.println("[null]"); System.out.println("[null]");
} }