8001457: New tests needed for library-side changes for repeating annotations

Wed, 13 Feb 2013 23:05:17 -0800

author
darcy
date
Wed, 13 Feb 2013 23:05:17 -0800
changeset 1576
63872da94576
parent 1566
3f9875aa5d67
child 1577
88286a36bb34

8001457: New tests needed for library-side changes for repeating annotations
Reviewed-by: darcy
Contributed-by: sonali.goel@oracle.com

test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java file | annotate | diff | comparison | revisions
test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java file | annotate | diff | comparison | revisions
test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedBase.java file | annotate | diff | comparison | revisions
test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedContainer.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java	Wed Feb 13 11:25:58 2013 -0800
     1.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java	Wed Feb 13 23:05:17 2013 -0800
     1.3 @@ -21,40 +21,51 @@
     1.4   * questions.
     1.5   */
     1.6  
     1.7 +import java.io.File;
     1.8 +import java.io.IOException;
     1.9  import java.net.URI;
    1.10  import java.net.URISyntaxException;
    1.11  import java.util.Arrays;
    1.12 +import java.util.Iterator;
    1.13 +
    1.14 +import javax.tools.Diagnostic;
    1.15  import javax.tools.DiagnosticCollector;
    1.16  import javax.tools.JavaCompiler;
    1.17 +import javax.tools.JavaCompiler.CompilationTask;
    1.18  import javax.tools.JavaFileObject;
    1.19  import javax.tools.SimpleJavaFileObject;
    1.20 +import javax.tools.StandardJavaFileManager;
    1.21 +import javax.tools.StandardLocation;
    1.22  import javax.tools.ToolProvider;
    1.23 -import javax.tools.JavaCompiler.CompilationTask;
    1.24 +
    1.25 +import com.sun.source.util.JavacTask;
    1.26  
    1.27  public class Helper {
    1.28  
    1.29      enum ContentVars {
    1.30 +
    1.31          IMPORTCONTAINERSTMTS("\nimport java.lang.annotation.Repeatable;\n"),
    1.32          IMPORTDEPRECATED("import java.lang.Deprecated;\n"),
    1.33          IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"),
    1.34          IMPORTINHERITED("import java.lang.annotation.Inherited;\n"),
    1.35 -        IMPORTRETENTION("import java.lang.annotation.Retention;\n" +
    1.36 -                        "\nimport java.lang.annotation.RetentionPolicy;\n"),
    1.37 +        IMPORTRETENTION("import java.lang.annotation.Retention;\n"
    1.38 +        + "\nimport java.lang.annotation.RetentionPolicy;\n"),
    1.39          IMPORTSTMTS("import java.lang.annotation.*;\n"),
    1.40 +        IMPORTEXPECTED("import expectedFiles.*;\n"),
    1.41          REPEATABLE("\n@Repeatable(FooContainer.class)\n"),
    1.42 -        CONTAINER("@interface FooContainer {\n" +"  Foo[] value();\n}\n"),
    1.43 +        CONTAINER("@interface FooContainer {\n" + "  Foo[] value();\n}\n"),
    1.44          BASE("@interface Foo {}\n"),
    1.45          BASEANNO("@Foo"),
    1.46 +        LEGACYCONTAINER("@FooContainer(value = {@Foo, @Foo})\n"),
    1.47          REPEATABLEANNO("\n@Foo() @Foo()"),
    1.48          DEPRECATED("\n@Deprecated"),
    1.49          DOCUMENTED("\n@Documented"),
    1.50          INHERITED("\n@Inherited"),
    1.51 +        TARGET("\n@Target(#VAL)\n"),
    1.52          RETENTION("@Retention(RetentionPolicy.#VAL)\n"),
    1.53 -        TARGET("\n@Target(#VAL)\n");
    1.54 -
    1.55 +        RETENTIONRUNTIME("@Retention(RetentionPolicy.RUNTIME)\n");
    1.56          private String val;
    1.57  
    1.58 -
    1.59          private ContentVars(String val) {
    1.60              this.val = val;
    1.61          }
    1.62 @@ -64,49 +75,6 @@
    1.63          }
    1.64      }
    1.65  
    1.66 -    /* String template where /*<TYPE>*/ /*gets replaced by repeating anno
    1.67 -     * Used to generate test src for combo tests
    1.68 -     *   - BasicSyntaxCombo.java
    1.69 -     *   - TargetAnnoCombo.java
    1.70 -     */
    1.71 -    public static final String template =
    1.72 -            "/*PACKAGE*/\n" +
    1.73 -            "//pkg test;\n\n" +
    1.74 -            "/*ANNODATA*/\n" + // import statements, declaration of Foo/FooContainer
    1.75 -            "/*TYPE*/ //class\n" +
    1.76 -            "class #ClassName {\n" +
    1.77 -            "  /*FIELD*/ //instance var\n" +
    1.78 -            "  public int x = 0;\n\n" +
    1.79 -            "  /*FIELD*/ //Enum constants\n" +
    1.80 -            "  TestEnum testEnum;\n\n" +
    1.81 -            "  /*FIELD*/ // Static field\n" +
    1.82 -            "  public static int num;\n\n" +
    1.83 -            "  /*STATIC_INI*/\n" +
    1.84 -            "  static { \n" + "num = 10; \n  }\n\n" +
    1.85 -            "  /*CONSTRUCTOR*/\n" +
    1.86 -            "  #ClassName() {}\n\n" +
    1.87 -            "  /*INSTANCE_INI*/\n" +
    1.88 -            "  { \n x = 10; \n }" +
    1.89 -            "  /*INNER_CLASS*/\n" +
    1.90 -            "  class innerClass {}\n" +
    1.91 -            "  /*METHOD*/\n" +
    1.92 -            "  void bar(/*PARAMETER*/ int baz) {\n" +
    1.93 -            "    /*LOCAL_VARIABLE*/\n" +
    1.94 -            "    int y = 0;\n" +
    1.95 -            "  }\n" +
    1.96 -            "}\n\n" +
    1.97 -            "/*TYPE*/ //Enum\n" +
    1.98 -            "enum TestEnum {}\n\n" +
    1.99 -            "/*TYPE*/ //Interface\n" +
   1.100 -            "interface TestInterface {}\n\n" +
   1.101 -            "/*TYPE*/\n" +
   1.102 -            "/*ANNOTATION_TYPE*/\n" +
   1.103 -            "@interface TestAnnotationType{}\n" +
   1.104 -            "class TestPkg {}\n" +
   1.105 -            "class TestTypeAnno </*TYPE_PARAMETER*/ T extends Object> {\n" +
   1.106 -            "  String /*TYPE_USE*/[] arr;\n" +
   1.107 -            "}";
   1.108 -
   1.109      // Create and compile FileObject using values for className and contents
   1.110      public static boolean compileCode(String className, String contents,
   1.111              DiagnosticCollector<JavaFileObject> diagnostics) {
   1.112 @@ -122,21 +90,96 @@
   1.113          CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnit);
   1.114          ok = task.call();
   1.115          return ok;
   1.116 +    }
   1.117 +    // Compile a list of FileObjects
   1.118 +    // Used when packages are needed and classes need to be loaded at runtime
   1.119 +    static File destDir = new File(System.getProperty("user.dir"));
   1.120  
   1.121 -    }
   1.122 -
   1.123 -    // Compile a list of FileObjects
   1.124      public static boolean compileCode(DiagnosticCollector<JavaFileObject> diagnostics, Iterable<? extends JavaFileObject> files) {
   1.125 +        boolean ok = false;
   1.126          JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
   1.127          if (compiler == null) {
   1.128              throw new RuntimeException("can't get javax.tools.JavaCompiler!");
   1.129          }
   1.130  
   1.131 -        CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
   1.132 -        boolean ok = task.call();
   1.133 +        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
   1.134 +
   1.135 +        // Assuming filesCount can maximum be 2 and if true, one file is package-info.java
   1.136 +        if (isPkgInfoPresent(files)) {
   1.137 +            JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
   1.138 +            try {
   1.139 +                fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
   1.140 +                task.generate();
   1.141 +            } catch (IOException ioe) {
   1.142 +                throw new RuntimeException("Compilation failed for package level tests", ioe);
   1.143 +            }
   1.144 +            int err = 0;
   1.145 +            for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
   1.146 +                if(d.getKind() == Diagnostic.Kind.ERROR) {
   1.147 +                  err++;
   1.148 +                }
   1.149 +            }
   1.150 +            ok = (err == 0);
   1.151 +        } else {
   1.152 +            CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
   1.153 +            ok = task.call();
   1.154 +        }
   1.155          return ok;
   1.156      }
   1.157  
   1.158 +    static private boolean isPkgInfoPresent(Iterable<? extends JavaFileObject> files) {
   1.159 +        Iterator<? extends JavaFileObject> itr = files.iterator();
   1.160 +        while (itr.hasNext()) {
   1.161 +            String name = itr.next().getName();
   1.162 +            if (name.contains("package-info")) {
   1.163 +                return true;
   1.164 +            }
   1.165 +        }
   1.166 +        return false;
   1.167 +    }
   1.168 +    /* String template where /*<TYPE>*/ /*gets replaced by repeating anno
   1.169 +     * Used to generate test src for combo tests
   1.170 +     *   - BasicSyntaxCombo.java
   1.171 +     *   - TargetAnnoCombo.java
   1.172 +     */
   1.173 +
   1.174 +    public static final String template =
   1.175 +            "/*PACKAGE*/\n"
   1.176 +            + "//pkg test;\n\n"
   1.177 +            + "/*TYPE*/ //class\n"
   1.178 +            + "class #ClassName {\n"
   1.179 +            + "  /*FIELD*/ //instance var\n"
   1.180 +            + "  public int x = 0;\n\n"
   1.181 +            + "  /*FIELD*/ //Enum constants\n"
   1.182 +            + "  TestEnum testEnum;\n\n"
   1.183 +            + "  /*FIELD*/ // Static field\n"
   1.184 +            + "  public static int num;\n\n"
   1.185 +            + "  /*STATIC_INI*/\n"
   1.186 +            + "  static { \n" + "num = 10; \n  }\n\n"
   1.187 +            + "  /*CONSTRUCTOR*/\n"
   1.188 +            + "  #ClassName() {}\n\n"
   1.189 +            + "  /*INSTANCE_INI*/\n"
   1.190 +            + "  { \n x = 10; \n }"
   1.191 +            + "  /*INNER_CLASS*/\n"
   1.192 +            + "  class innerClass {}\n"
   1.193 +            + "  /*METHOD*/\n"
   1.194 +            + "  void bar(/*PARAMETER*/ int baz) {\n"
   1.195 +            + "    /*LOCAL_VARIABLE*/\n"
   1.196 +            + "    int y = 0;\n"
   1.197 +            + "  }\n"
   1.198 +            + "}\n\n"
   1.199 +            + "/*TYPE*/ //Enum\n"
   1.200 +            + "enum TestEnum {}\n\n"
   1.201 +            + "/*TYPE*/ //Interface\n"
   1.202 +            + "interface TestInterface {}\n\n"
   1.203 +            + "/*TYPE*/\n"
   1.204 +            + "/*ANNOTATION_TYPE*/\n"
   1.205 +            + "@interface TestAnnotationType{}\n"
   1.206 +            + "class TestPkg {}\n"
   1.207 +            + "class TestTypeAnno </*TYPE_PARAMETER*/ T extends Object> {\n"
   1.208 +            + "  String /*TYPE_USE*/[] arr;\n"
   1.209 +            + "}";
   1.210 +
   1.211      static JavaFileObject getFile(String name, String code) {
   1.212          JavaFileObject o = null;
   1.213          try {
   1.214 @@ -146,16 +189,19 @@
   1.215          }
   1.216          return o;
   1.217      }
   1.218 +
   1.219      static class JavaStringFileObject extends SimpleJavaFileObject {
   1.220 +
   1.221          final String theCode;
   1.222 +
   1.223          public JavaStringFileObject(String fileName, String theCode) throws URISyntaxException {
   1.224 -            super(new URI("string:///" + fileName.replace('.','/') + ".java"), Kind.SOURCE);
   1.225 +            super(new URI("string:///" + fileName.replace('.', '/') + ".java"), Kind.SOURCE);
   1.226              this.theCode = theCode;
   1.227          }
   1.228 +
   1.229          @Override
   1.230          public CharSequence getCharContent(boolean ignoreEncodingErrors) {
   1.231              return theCode;
   1.232          }
   1.233      }
   1.234  }
   1.235 -
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java	Wed Feb 13 23:05:17 2013 -0800
     2.3 @@ -0,0 +1,2932 @@
     2.4 +/*
     2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/**
    2.28 + * @test
    2.29 + * @bug      8001457
    2.30 + * @author   sogoel
    2.31 + * @summary  Reflection api tests
    2.32 + * @build    Helper
    2.33 + * @compile  expectedFiles/ExpectedBase.java expectedFiles/ExpectedContainer.java
    2.34 + * @run main ReflectionTest
    2.35 + */
    2.36 +import java.io.File;
    2.37 +import java.io.IOException;
    2.38 +import java.lang.annotation.Annotation;
    2.39 +import java.net.MalformedURLException;
    2.40 +import java.net.URL;
    2.41 +import java.net.URLClassLoader;
    2.42 +import java.util.ArrayList;
    2.43 +import java.util.Arrays;
    2.44 +import java.util.List;
    2.45 +
    2.46 +import javax.tools.DiagnosticCollector;
    2.47 +import javax.tools.JavaFileObject;
    2.48 +
    2.49 +import expectedFiles.ExpectedBase;
    2.50 +import expectedFiles.ExpectedContainer;
    2.51 +
    2.52 +/*
    2.53 + * Objective:
    2.54 + * Test the following 6 methods from java.lang.reflect.AnnotatedElement:
    2.55 + * - getAnnotation(Class<T>)
    2.56 + * - getAnnotations()
    2.57 + * - getDeclaredAnnotations()
    2.58 + * - getDeclaredAnnotation(Class<T>)  // new method in JDK8
    2.59 + * - getAnnotationsByType(Class<T>)         // new method in JDK8
    2.60 + * - getDeclaredAnnotationsByType(Class<T>) // new method in JDK8
    2.61 + * for multiple test cases, for example, BasicNonRepeatable case, BasicRepeatable case
    2.62 + * for each of the src types - class, method, field, package
    2.63 + *
    2.64 + * This test uses following three enums:
    2.65 + * 1. TestCase - Defines the ExpectedBase/ExpectedContainer values for each testCase
    2.66 + *             - getTestFiles() - Creates list of JavaFileObjects for the primary
    2.67 + *                                src types (class, method, field, package)
    2.68 + *             - Each testCase is a new scenario with a combination of @Repeatable
    2.69 + *               relationship present/absent in conjunction with @Inherited.
    2.70 + *               For eg: BasicNonRepeatable_Legacy - It is a pre-JDK8 way of writing a single
    2.71 + *                       annotation on a given srcType( class, method, field, package)
    2.72 + *                       BasicRepeatable - It is a JDK8 way of writing repeating annotations
    2.73 + *                       on a given srcType with a @Repeatable relationship
    2.74 + *                       defined between Foo and FooContainer.
    2.75 + *
    2.76 + * 2. SrcType - Defines templates used in creation of test src
    2.77 + *            - Defines getExpectedBase() and getExpectedContainer() for primary src types
    2.78 + * 3. TestMethod - Defines getActualAnnoBase(), getActualAnnoContainer(), getExpectedAnnoBase(),
    2.79 + *                 and getExpectedAnnoContainer() for each of the 6 methods that are being tested
    2.80 + *                 in java.lang.reflect.AnnotatedElement
    2.81 + *
    2.82 + * Test execution flow:
    2.83 + * - Loop over each of the src types and each test cases
    2.84 + * - Creates test src for each flow, compile it, load the class object
    2.85 + * - Run all 6 methods on this class object
    2.86 + * - Get expected and actual annotations for each object and compare them.
    2.87 + * - Increment the error counter if the annotations don't match.
    2.88 + *
    2.89 + * The test fails if the number of errors is greater than 0.
    2.90 + */
    2.91 +public class ReflectionTest {
    2.92 +
    2.93 +    static int errors = 0;
    2.94 +    // Variables used in creating test src for a given testcase/testSrcType
    2.95 +    static final String TESTPKG = "testpkg";
    2.96 +    static final String TESTMETHOD = "testMethod";
    2.97 +    static final String TESTFIELD = "testField";
    2.98 +    static final String PKGINFONAME = TESTPKG + ".package-info";
    2.99 +    static final String SUPERCLASS = "SuperClass";
   2.100 +    static final String TESTINTERFACE = "TestInterface";
   2.101 +    /*
   2.102 +     *  Set it to true to get more debug information
   2.103 +     */
   2.104 +    static final boolean DEBUG = false;
   2.105 +
   2.106 +    public static void main(String args[]) throws Exception {
   2.107 +        ReflectionTest test = new ReflectionTest();
   2.108 +        test.runTest();
   2.109 +    }
   2.110 +
   2.111 +    public void runTest() throws Exception {
   2.112 +
   2.113 +        ClassLoader parentClassLoader = getLoader();
   2.114 +        String className = "";
   2.115 +        Iterable<? extends JavaFileObject> files = null;
   2.116 +
   2.117 +        for (SrcType srcType : SrcType.getSrcTypes()) {
   2.118 +            for (TestCase testCase : TestCase.values()) {
   2.119 +                className = testCase + "_" + srcType;
   2.120 +                debugPrint("*****************************************");
   2.121 +                System.out.println("Running Test for ClassName: " + className);
   2.122 +
   2.123 +                // @Inherited only applicable for class, exclude cases for
   2.124 +                // package, method, field
   2.125 +                if (testCase.name().contains("Inherited")
   2.126 +                        && (srcType != SrcType.CLASS)) {
   2.127 +                    continue;
   2.128 +                }
   2.129 +
   2.130 +                // Get list of JavaFileObjects to be compiled
   2.131 +                files = testCase.getTestFiles(srcType, className);
   2.132 +                if (srcType == SrcType.PACKAGE) {
   2.133 +                    className = TESTPKG + "." + className;
   2.134 +                }
   2.135 +                DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
   2.136 +
   2.137 +                // Compile the list of JavaFileObjects
   2.138 +                try {
   2.139 +                    Helper.compileCode(diagnostics, files);
   2.140 +                } catch (Exception ex) {
   2.141 +                    printTestSrc(files);
   2.142 +                    throw new RuntimeException(
   2.143 +                            "Exception when compiling class " + className, ex);
   2.144 +                }
   2.145 +
   2.146 +                // Get Class object for the compiled class
   2.147 +                Class<?> c = loadClass(className, parentClassLoader, Helper.destDir);
   2.148 +                if (c != null) {
   2.149 +                    // For the loaded class object, compare expected and actual annotation values
   2.150 +                    // for each of the methods under test from java.lang.reflect.AnnotatedElement
   2.151 +                    checkAnnoValues(srcType, c);
   2.152 +                } else {
   2.153 +                    error("Could not load className = " + c);
   2.154 +                }
   2.155 +            }
   2.156 +        }
   2.157 +
   2.158 +        if (getNumErrors() > 0) {
   2.159 +            System.err.println("Test failed with " + getNumErrors() + " errors");
   2.160 +            throw new RuntimeException();
   2.161 +        }
   2.162 +    }
   2.163 +
   2.164 +    /*
   2.165 +     *  Each test case in this enum has the following:
   2.166 +     *  - Define each test case with its @ExpectedBase and @ExpectedContainer annotations
   2.167 +     *  - Override getTestFiles() that creates list of JavaFileObjects for each case
   2.168 +     *    based on the src type.
   2.169 +     */
   2.170 +    enum TestCase {
   2.171 +        BasicNonRepeatable_Legacy(
   2.172 +        "@ExpectedBase(value=Foo.class, "
   2.173 +                + "getAnnotationVal = \"Foo\", "
   2.174 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
   2.175 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
   2.176 +                + "getDeclAnnoVal = \"Foo\", "
   2.177 +                + "getAnnosArgs = {\"Foo\"}, "
   2.178 +                + "getDeclAnnosArgs = {\"Foo\"}) ",
   2.179 +        "@ExpectedContainer") {
   2.180 +
   2.181 +            @Override
   2.182 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.183 +                    String className) {
   2.184 +                String anno = "";
   2.185 +                String replaceVal = "";
   2.186 +                String testSrc = "";
   2.187 +                String pkgInfoContents = "";
   2.188 +                String contents = "";
   2.189 +
   2.190 +                JavaFileObject pkgFileObj = null;
   2.191 +                JavaFileObject srcFileObj = null;
   2.192 +                Iterable<? extends JavaFileObject> files = null;
   2.193 +
   2.194 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.195 +                        + getExpectedContainer() + "\n";
   2.196 +                StringBuilder commonStmts = new StringBuilder();
   2.197 +                anno = Helper.ContentVars.BASEANNO.getVal();
   2.198 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
   2.199 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
   2.200 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.201 +                        .append(Helper.ContentVars.BASE.getVal());
   2.202 +                switch (srcType) {
   2.203 +                    case PACKAGE:
   2.204 +                        /*
   2.205 +                        Sample package-info.java
   2.206 +                        @ExpectedBase
   2.207 +                        @ExpectedContainer
   2.208 +                        @Foo
   2.209 +                        package testpkg;
   2.210 +
   2.211 +                        @Retention(RetentionPolicy.RUNTIME)
   2.212 +                        @interface Foo {}
   2.213 +
   2.214 +                        Sample testSrc:
   2.215 +                        package testpkg;
   2.216 +                        class A {}
   2.217 +                         */
   2.218 +                        testSrc = srcType.getTemplate().replace("#CN", className);
   2.219 +                        contents = testSrc;
   2.220 +                        srcFileObj = Helper.getFile(className, contents);
   2.221 +
   2.222 +                        replaceVal = expectedVals + "\n" + anno;
   2.223 +                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
   2.224 +                                .replace("#REPLACE1", replaceVal)
   2.225 +                                .replace("#REPLACE2", commonStmts);
   2.226 +                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
   2.227 +
   2.228 +                        files = Arrays.asList(pkgFileObj, srcFileObj);
   2.229 +                        break;
   2.230 +                    default:
   2.231 +                        // class, method, field
   2.232 +                    /*
   2.233 +                        Sample testSrc for class
   2.234 +                        @Retention(RetentionPolicy.RUNTIME)
   2.235 +                        @interface Foo {}
   2.236 +
   2.237 +                        @ExpectedBase
   2.238 +                        @ExpectedContainer
   2.239 +                        @Foo
   2.240 +                        class A {}
   2.241 +                         */
   2.242 +                        replaceVal = expectedVals + anno;
   2.243 +                        testSrc = srcType.getTemplate().replace("#CN", className)
   2.244 +                                .replace("#REPLACE", replaceVal);
   2.245 +                        contents = commonStmts + testSrc;
   2.246 +                        srcFileObj = Helper.getFile(className, contents);
   2.247 +                        files = Arrays.asList(srcFileObj);
   2.248 +                }
   2.249 +                return files;
   2.250 +            }
   2.251 +        },
   2.252 +        SingleAnnoInherited_Legacy(
   2.253 +        "@ExpectedBase(value=Foo.class, "
   2.254 +                + "getAnnotationVal = \"Foo\", "
   2.255 +                + "getAnnotationsVals = {\"Foo\", \"ExpectedBase\", \"ExpectedContainer\"}, "
   2.256 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
   2.257 +                + "getDeclAnnoVal = \"NULL\", "
   2.258 +                + "getAnnosArgs = {\"Foo\"}, "
   2.259 +                + "getDeclAnnosArgs = {})",
   2.260 +        "@ExpectedContainer") {
   2.261 +
   2.262 +            @Override
   2.263 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.264 +                    String className) {
   2.265 +                String anno = "";
   2.266 +                String replaceVal = "";
   2.267 +                String contents = "";
   2.268 +                JavaFileObject srcFileObj = null;
   2.269 +                Iterable<? extends JavaFileObject> files = null;
   2.270 +
   2.271 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.272 +                        + getExpectedContainer() + "\n";
   2.273 +                StringBuilder commonStmts = new StringBuilder();
   2.274 +
   2.275 +                /*
   2.276 +                Sample testSrc:
   2.277 +                @Retention(RetentionPolicy.RUNTIME)
   2.278 +                @Inherited
   2.279 +                @interface Foo {}
   2.280 +
   2.281 +                @Foo
   2.282 +                class SuperClass { }
   2.283 +
   2.284 +                @ExpectedBase
   2.285 +                @ExpectedContainer
   2.286 +                class SubClass extends SuperClass {}
   2.287 +                 */
   2.288 +
   2.289 +                // @Inherited only works for classes, no switch cases for
   2.290 +                // method, field, package
   2.291 +                anno = Helper.ContentVars.BASEANNO.getVal();
   2.292 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
   2.293 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
   2.294 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.295 +                        .append(Helper.ContentVars.INHERITED.getVal())
   2.296 +                        .append(Helper.ContentVars.BASE.getVal());
   2.297 +
   2.298 +                if (srcType == SrcType.CLASS) {
   2.299 +                    // Contents for SuperClass
   2.300 +                    replaceVal = commonStmts + "\n" + anno;
   2.301 +                    String superClassContents = srcType.getTemplate()
   2.302 +                            .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal);
   2.303 +
   2.304 +                    // Contents for SubClass that extends SuperClass
   2.305 +                    replaceVal = expectedVals;
   2.306 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
   2.307 +                            .replace("#CN", className).replace("#SN", SUPERCLASS)
   2.308 +                            .replace("#REPLACE", replaceVal);
   2.309 +
   2.310 +                    contents = superClassContents + subClassContents;
   2.311 +                    srcFileObj = Helper.getFile(className, contents);
   2.312 +                    files = Arrays.asList(srcFileObj);
   2.313 +                }
   2.314 +                return files;
   2.315 +            }
   2.316 +        },
   2.317 +        InheritedAnnoOnInterface_Legacy(
   2.318 +        "@ExpectedBase(value=Foo.class, "
   2.319 +                + "getAnnotationVal = \"NULL\", "
   2.320 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
   2.321 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"},"
   2.322 +                + "getDeclAnnoVal = \"NULL\"," + "getAnnosArgs = {},"
   2.323 +                + "getDeclAnnosArgs = {})",
   2.324 +        "@ExpectedContainer") {
   2.325 +
   2.326 +            @Override
   2.327 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.328 +                    String className) {
   2.329 +                String anno = "";
   2.330 +                String replaceVal = "";
   2.331 +                String contents = "";
   2.332 +                JavaFileObject srcFileObj = null;
   2.333 +                Iterable<? extends JavaFileObject> files = null;
   2.334 +
   2.335 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.336 +                        + getExpectedContainer() + "\n";
   2.337 +                StringBuilder commonStmts = new StringBuilder();
   2.338 +
   2.339 +                /*
   2.340 +                Sample test src:
   2.341 +                @Retention(RetentionPolicy.RUNTIME)
   2.342 +                @Inherited
   2.343 +                @interface Foo {}
   2.344 +
   2.345 +                @Foo
   2.346 +                interface TestInterface { }
   2.347 +
   2.348 +                @ExpectedBase
   2.349 +                @ExpectedContainer
   2.350 +                class A implements TestInterface {}
   2.351 +                 */
   2.352 +                anno = Helper.ContentVars.BASEANNO.getVal();
   2.353 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
   2.354 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
   2.355 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.356 +                        .append(Helper.ContentVars.INHERITED.getVal())
   2.357 +                        .append(Helper.ContentVars.BASE.getVal());
   2.358 +
   2.359 +                if (srcType == SrcType.CLASS) {
   2.360 +                    // Contents for TestInterface
   2.361 +                    replaceVal = commonStmts + "\n" + anno;
   2.362 +                    String interfaceContents = SrcType.INTERFACE.getTemplate()
   2.363 +                            .replace("#IN", TESTINTERFACE)
   2.364 +                            .replace("#REPLACE", replaceVal);
   2.365 +
   2.366 +                    // Contents for class implementing TestInterface
   2.367 +                    replaceVal = expectedVals;
   2.368 +                    String classContents = SrcType.INTERFACEIMPL.getTemplate()
   2.369 +                            .replace("#CN", className).replace("#IN", TESTINTERFACE)
   2.370 +                            .replace("#REPLACE", replaceVal);
   2.371 +
   2.372 +                    contents = interfaceContents + classContents;
   2.373 +                    srcFileObj = Helper.getFile(className, contents);
   2.374 +                    files = Arrays.asList(srcFileObj);
   2.375 +                }
   2.376 +                return files;
   2.377 +            }
   2.378 +        },
   2.379 +        AnnoOnSuperAndSubClass_Inherited_Legacy(
   2.380 +        "@ExpectedBase(value=Foo.class, "
   2.381 +                + "getAnnotationVal = \"Foo\", "
   2.382 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
   2.383 +                + // override every annotation on superClass
   2.384 +                "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
   2.385 +                + // ignores inherited annotations
   2.386 +                "getDeclAnnoVal = \"Foo\", " // ignores inherited
   2.387 +                + "getAnnosArgs = {\"Foo\"}, "
   2.388 +                + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
   2.389 +        "@ExpectedContainer(value=FooContainer.class, "
   2.390 +                + "getAnnotationVal = \"NULL\", "
   2.391 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
   2.392 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
   2.393 +                + // ignores inherited annotations
   2.394 +                "getDeclAnnoVal = \"NULL\", " + // ignores inherited
   2.395 +                "getAnnosArgs = {}, " + "getDeclAnnosArgs = {})") { // ignores inherited
   2.396 +
   2.397 +            @Override
   2.398 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.399 +                    String className) {
   2.400 +                String anno = "";
   2.401 +                String replaceVal = "";
   2.402 +                String contents = "";
   2.403 +                JavaFileObject srcFileObj = null;
   2.404 +                Iterable<? extends JavaFileObject> files = null;
   2.405 +
   2.406 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.407 +                        + getExpectedContainer() + "\n";
   2.408 +                StringBuilder commonStmts = new StringBuilder();
   2.409 +
   2.410 +                /*
   2.411 +                Sample test src
   2.412 +                @Retention(RetentionPolicy.RUNTIME)
   2.413 +                @Inherited
   2.414 +                @interface Foo {}
   2.415 +
   2.416 +                @Inherited
   2.417 +                @interface FooContainer {
   2.418 +                Foo[] value();
   2.419 +                }
   2.420 +
   2.421 +                @Foo
   2.422 +                class SuperClass { }
   2.423 +
   2.424 +                @ExpectedBase
   2.425 +                @ExpectedContainer
   2.426 +                @Foo
   2.427 +                class SubClass extends SuperClass {}
   2.428 +                 */
   2.429 +                // @Inherited only works for classes, no switch cases for
   2.430 +                // method, field, package
   2.431 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
   2.432 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
   2.433 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.434 +                        .append(Helper.ContentVars.INHERITED.getVal())
   2.435 +                        .append(Helper.ContentVars.BASE.getVal())
   2.436 +                        .append(Helper.ContentVars.INHERITED.getVal())
   2.437 +                        .append(Helper.ContentVars.CONTAINER.getVal());
   2.438 +
   2.439 +                if (srcType == SrcType.CLASS) {
   2.440 +                    // Contents for SuperClass
   2.441 +                    anno = Helper.ContentVars.BASEANNO.getVal();
   2.442 +                    replaceVal = commonStmts + "\n" + anno;
   2.443 +                    String superClassContents = srcType.getTemplate()
   2.444 +                            .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal);
   2.445 +
   2.446 +                    // Contents for SubClass that extends SuperClass
   2.447 +                    replaceVal = expectedVals + "\n" + anno;
   2.448 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
   2.449 +                            .replace("#CN", className).replace("#SN", SUPERCLASS)
   2.450 +                            .replace("#REPLACE", replaceVal);
   2.451 +
   2.452 +                    contents = superClassContents + subClassContents;
   2.453 +                    srcFileObj = Helper.getFile(className, contents);
   2.454 +                    files = Arrays.asList(srcFileObj);
   2.455 +                }
   2.456 +                return files;
   2.457 +            }
   2.458 +        },
   2.459 +        BasicContainer_Legacy(
   2.460 +        "@ExpectedBase(value = Foo.class, "
   2.461 +                + "getAnnotationVal = \"NULL\","
   2.462 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
   2.463 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
   2.464 +                + "getDeclAnnoVal = \"NULL\", " + "getAnnosArgs = {}, "
   2.465 +                + "getDeclAnnosArgs = {} )",
   2.466 +        "@ExpectedContainer(value=FooContainer.class, "
   2.467 +                + "getAnnotationVal = \"FooContainer\", "
   2.468 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
   2.469 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
   2.470 +                + "getDeclAnnoVal = \"FooContainer\", "
   2.471 +                + "getAnnosArgs = {\"FooContainer\"}, "
   2.472 +                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
   2.473 +
   2.474 +            @Override
   2.475 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.476 +                    String className) {
   2.477 +                String anno = "";
   2.478 +                String replaceVal = "";
   2.479 +                String testSrc = "";
   2.480 +                String pkgInfoContents = "";
   2.481 +                String contents = "";
   2.482 +
   2.483 +                JavaFileObject pkgFileObj = null;
   2.484 +                JavaFileObject srcFileObj = null;
   2.485 +                Iterable<? extends JavaFileObject> files = null;
   2.486 +
   2.487 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.488 +                        + getExpectedContainer() + "\n";
   2.489 +                StringBuilder commonStmts = new StringBuilder();
   2.490 +
   2.491 +                anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
   2.492 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
   2.493 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
   2.494 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.495 +                        .append(Helper.ContentVars.BASE.getVal())
   2.496 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.497 +                        .append(Helper.ContentVars.CONTAINER.getVal());
   2.498 +                switch (srcType) {
   2.499 +                    case PACKAGE:
   2.500 +                        /*
   2.501 +                        Sample package-info.java
   2.502 +                        @ExpectedBase
   2.503 +                        @ExpectedContainer
   2.504 +                        @FooContainer(value = {@Foo, @Foo})
   2.505 +                        package testpkg;
   2.506 +
   2.507 +                        @Retention(RetentionPolicy.RUNTIME)
   2.508 +                        @interface Foo {}
   2.509 +
   2.510 +                        @Retention(RetentionPolicy.RUNTIME)
   2.511 +                        @interface FooContainer {
   2.512 +                        Foo[] value();
   2.513 +                        }
   2.514 +
   2.515 +                        Sample testSrc:
   2.516 +                        package testpkg;
   2.517 +                        class A {}
   2.518 +                         */
   2.519 +                        testSrc = srcType.getTemplate().replace("#CN", className);
   2.520 +                        contents = testSrc;
   2.521 +                        srcFileObj = Helper.getFile(className, contents);
   2.522 +
   2.523 +                        replaceVal = "\n" + expectedVals + "\n" + anno;
   2.524 +                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
   2.525 +                                .replace("#REPLACE1", replaceVal)
   2.526 +                                .replace("#REPLACE2", commonStmts);
   2.527 +                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
   2.528 +                        files = Arrays.asList(pkgFileObj, srcFileObj);
   2.529 +                        break;
   2.530 +                    default:
   2.531 +                        /*
   2.532 +                        Sample testSrc for class:
   2.533 +                        @Retention(RetentionPolicy.RUNTIME)
   2.534 +                        @Inherited
   2.535 +                        @interface Foo {}
   2.536 +
   2.537 +                        @Retention(RetentionPolicy.RUNTIME)
   2.538 +                        @Inherited
   2.539 +                        @interface FooContainer {
   2.540 +                        Foo[] value();
   2.541 +                        }
   2.542 +
   2.543 +                        @ExpectedBase
   2.544 +                        @ExpectedContainer
   2.545 +                        @FooContainer(value = {@Foo, @Foo})
   2.546 +                        class A {}
   2.547 +                         */
   2.548 +                        replaceVal = expectedVals + anno;
   2.549 +                        testSrc = srcType.getTemplate().replace("#CN", className)
   2.550 +                                .replace("#REPLACE", replaceVal);
   2.551 +                        contents = commonStmts + testSrc;
   2.552 +                        srcFileObj = Helper.getFile(className, contents);
   2.553 +                        files = Arrays.asList(srcFileObj);
   2.554 +                }
   2.555 +                return files;
   2.556 +            }
   2.557 +        },
   2.558 +        SingleAndContainerOnSuper_Legacy(
   2.559 +        "@ExpectedBase(value = Foo.class, "
   2.560 +                + "getAnnotationVal = \"Foo\","
   2.561 +                + "getAnnotationsVals = {"
   2.562 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.563 +                + "getDeclAnnosVals = {"
   2.564 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.565 +                + "getDeclAnnoVal = \"Foo\", "
   2.566 +                + "getAnnosArgs = {\"Foo\"}, "
   2.567 +                + "getDeclAnnosArgs = {\"Foo\"} )",
   2.568 +        "@ExpectedContainer(value=FooContainer.class, "
   2.569 +                + "getAnnotationVal = \"FooContainer\", "
   2.570 +                + "getAnnotationsVals = {"
   2.571 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.572 +                + "getDeclAnnosVals = {"
   2.573 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.574 +                + "getDeclAnnoVal = \"FooContainer\", "
   2.575 +                + "getAnnosArgs = {\"FooContainer\"}, "
   2.576 +                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
   2.577 +
   2.578 +            @Override
   2.579 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.580 +                    String className) {
   2.581 +                String anno = "";
   2.582 +                String replaceVal = "";
   2.583 +                String testSrc = "";
   2.584 +                String pkgInfoContents = "";
   2.585 +                String contents = "";
   2.586 +
   2.587 +                JavaFileObject pkgFileObj = null;
   2.588 +                JavaFileObject srcFileObj = null;
   2.589 +                Iterable<? extends JavaFileObject> files = null;
   2.590 +
   2.591 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.592 +                        + getExpectedContainer() + "\n";
   2.593 +                StringBuilder commonStmts = new StringBuilder();
   2.594 +
   2.595 +                anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
   2.596 +                        + Helper.ContentVars.BASEANNO.getVal();
   2.597 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
   2.598 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
   2.599 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.600 +                        .append(Helper.ContentVars.BASE.getVal())
   2.601 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
   2.602 +                        .append(Helper.ContentVars.CONTAINER.getVal());
   2.603 +                switch (srcType) {
   2.604 +                    case PACKAGE:
   2.605 +                        /*
   2.606 +                        Sample package-info.java
   2.607 +                        @ExpectedBase
   2.608 +                        @ExpectedContainer
   2.609 +                        @Foo
   2.610 +                        @FooContainer(value = {@Foo, @Foo})
   2.611 +                        package testpkg;
   2.612 +
   2.613 +                        @Retention(RetentionPolicy.RUNTIME)
   2.614 +                        @interface Foo {}
   2.615 +
   2.616 +                        @Retention(RetentionPolicy.RUNTIME)
   2.617 +                        @interface FooContainer {
   2.618 +                        Foo[] value();
   2.619 +                        }
   2.620 +
   2.621 +                        Sample testSrc:
   2.622 +                        package testpkg;
   2.623 +                        class A {}
   2.624 +                         */
   2.625 +                        testSrc = srcType.getTemplate().replace("#CN", className);
   2.626 +                        contents = testSrc;
   2.627 +
   2.628 +                        srcFileObj = Helper.getFile(className, contents);
   2.629 +
   2.630 +                        replaceVal = "\n" + expectedVals + "\n" + anno;
   2.631 +                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
   2.632 +                                .replace("#REPLACE1", replaceVal)
   2.633 +                                .replace("#REPLACE2", commonStmts);
   2.634 +                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
   2.635 +                        files = Arrays.asList(pkgFileObj, srcFileObj);
   2.636 +                        break;
   2.637 +                    default:
   2.638 +                        /*
   2.639 +                        Sample testSrc for class:
   2.640 +                        @Retention(RetentionPolicy.RUNTIME)
   2.641 +                        @Inherited
   2.642 +                        @interface Foo {}
   2.643 +
   2.644 +                        @Retention(RetentionPolicy.RUNTIME)
   2.645 +                        @Inherited
   2.646 +                        @interface FooContainer {
   2.647 +                        Foo[] value();
   2.648 +                        }
   2.649 +
   2.650 +                        @ExpectedBase
   2.651 +                        @ExpectedContainer
   2.652 +                        @Foo
   2.653 +                        @FooContainer(value = {@Foo, @Foo})
   2.654 +                        class A {}
   2.655 +                         */
   2.656 +                        replaceVal = expectedVals + anno;
   2.657 +                        testSrc = srcType.getTemplate().replace("#CN", className)
   2.658 +                                .replace("#REPLACE", replaceVal);
   2.659 +                        contents = commonStmts + testSrc;
   2.660 +
   2.661 +                        srcFileObj = Helper.getFile(className, contents);
   2.662 +                        files = Arrays.asList(srcFileObj);
   2.663 +                }
   2.664 +                return files;
   2.665 +            }
   2.666 +        },
   2.667 +        BasicContainer_Inherited_Legacy(
   2.668 +        "@ExpectedBase(value = Foo.class, "
   2.669 +                + "getAnnotationVal = \"NULL\","
   2.670 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
   2.671 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
   2.672 +                + "getDeclAnnoVal = \"NULL\", "
   2.673 +                + "getAnnosArgs = {}, "
   2.674 +                + "getDeclAnnosArgs = {} )",
   2.675 +        "@ExpectedContainer(value=FooContainer.class, "
   2.676 +                + "getAnnotationVal = \"FooContainer\", "
   2.677 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
   2.678 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
   2.679 +                + "getDeclAnnoVal = \"NULL\", "
   2.680 +                + "getAnnosArgs = {\"FooContainer\"}, "
   2.681 +                + "getDeclAnnosArgs = {} )") {
   2.682 +
   2.683 +            @Override
   2.684 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.685 +                    String className) {
   2.686 +                String anno = "";
   2.687 +                String replaceVal = "";
   2.688 +                String contents = "";
   2.689 +                JavaFileObject srcFileObj = null;
   2.690 +                Iterable<? extends JavaFileObject> files = null;
   2.691 +
   2.692 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.693 +                        + getExpectedContainer() + "\n";
   2.694 +                StringBuilder commonStmts = getCommonStmts(false);
   2.695 +
   2.696 +                /*
   2.697 +                Sample testSrc:
   2.698 +                @Retention(RetentionPolicy.RUNTIME)
   2.699 +                @Inherited
   2.700 +                @interface Foo {}
   2.701 +
   2.702 +                @Retention(RetentionPolicy.RUNTIME)
   2.703 +                @Inherited
   2.704 +                @interface FooContainer {
   2.705 +                Foo[] value();
   2.706 +                }
   2.707 +
   2.708 +                @FooContainer(value = {@Foo, @Foo})
   2.709 +                class SuperClass { }
   2.710 +
   2.711 +                @ExpectedBase
   2.712 +                @ExpectedContainer
   2.713 +                class SubClass extends SuperClass {}
   2.714 +                 */
   2.715 +                // @Inherited only works for classes, no switch cases for
   2.716 +                // method, field, package
   2.717 +
   2.718 +                if (srcType == SrcType.CLASS) {
   2.719 +                    // Contents for SuperClass
   2.720 +                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
   2.721 +                    replaceVal = commonStmts + "\n" + anno;
   2.722 +                    String superClassContents = srcType.getTemplate()
   2.723 +                            .replace("#CN", SUPERCLASS)
   2.724 +                            .replace("#REPLACE", replaceVal);
   2.725 +
   2.726 +                    // Contents for SubClass that extends SuperClass
   2.727 +                    replaceVal = expectedVals;
   2.728 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
   2.729 +                            .replace("#CN", className)
   2.730 +                            .replace("#SN", SUPERCLASS)
   2.731 +                            .replace("#REPLACE", replaceVal);
   2.732 +
   2.733 +                    contents = superClassContents + subClassContents;
   2.734 +                    srcFileObj = Helper.getFile(className, contents);
   2.735 +                    files = Arrays.asList(srcFileObj);
   2.736 +                }
   2.737 +                return files;
   2.738 +            }
   2.739 +        },
   2.740 +        ContainerOnSuperSingleOnSub_Inherited_Legacy(
   2.741 +        "@ExpectedBase(value=Foo.class, "
   2.742 +                + "getAnnotationVal = \"Foo\", "
   2.743 +                + "getAnnotationsVals = {"
   2.744 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.745 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
   2.746 +                + "getDeclAnnoVal = \"Foo\","
   2.747 +                + "getAnnosArgs = {\"Foo\"},"
   2.748 +                + "getDeclAnnosArgs = {\"Foo\"})",
   2.749 +        "@ExpectedContainer(value=FooContainer.class, "
   2.750 +                + "getAnnotationVal = \"FooContainer\", "
   2.751 +                + "getAnnotationsVals = {"
   2.752 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.753 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
   2.754 +                + "getDeclAnnoVal = \"NULL\","
   2.755 +                + "getAnnosArgs = {\"FooContainer\"},"
   2.756 +                + "getDeclAnnosArgs = {})") {
   2.757 +
   2.758 +            @Override
   2.759 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.760 +                    String className) {
   2.761 +                String anno = "";
   2.762 +                String replaceVal = "";
   2.763 +                String contents = "";
   2.764 +                JavaFileObject srcFileObj = null;
   2.765 +                Iterable<? extends JavaFileObject> files = null;
   2.766 +
   2.767 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.768 +                        + getExpectedContainer() + "\n";
   2.769 +                StringBuilder commonStmts = getCommonStmts(false);
   2.770 +
   2.771 +                /*
   2.772 +                Sample testSrc:
   2.773 +                @Retention(RetentionPolicy.RUNTIME)
   2.774 +                @Inherited
   2.775 +                @interface Foo {}
   2.776 +
   2.777 +                @Retention(RetentionPolicy.RUNTIME)
   2.778 +                @Inherited
   2.779 +                @interface FooContainer {
   2.780 +                Foo[] value();
   2.781 +                }
   2.782 +
   2.783 +                @FooContainer(value = {@Foo, @Foo})
   2.784 +                class SuperClass { }
   2.785 +
   2.786 +                @ExpectedBase
   2.787 +                @ExpectedContainer
   2.788 +                @Foo
   2.789 +                class SubClass extends SuperClass {}
   2.790 +                 */
   2.791 +                // @Inherited only works for classes, no switch cases for
   2.792 +                // method, field, package
   2.793 +
   2.794 +                if (srcType == SrcType.CLASS) {
   2.795 +                    // Contents for SuperClass
   2.796 +                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
   2.797 +                    replaceVal = commonStmts + "\n" + anno;
   2.798 +                    String superClassContents = srcType.getTemplate()
   2.799 +                            .replace("#CN", SUPERCLASS)
   2.800 +                            .replace("#REPLACE", replaceVal);
   2.801 +
   2.802 +                    // Contents for SubClass that extends SuperClass
   2.803 +                    anno = Helper.ContentVars.BASEANNO.getVal();
   2.804 +                    replaceVal = expectedVals + "\n" + anno;
   2.805 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
   2.806 +                            .replace("#CN", className)
   2.807 +                            .replace("#SN", SUPERCLASS)
   2.808 +                            .replace("#REPLACE", replaceVal);
   2.809 +
   2.810 +                    contents = superClassContents + subClassContents;
   2.811 +                    srcFileObj = Helper.getFile(className, contents);
   2.812 +                    files = Arrays.asList(srcFileObj);
   2.813 +                }
   2.814 +                return files;
   2.815 +            }
   2.816 +        },
   2.817 +        ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy(
   2.818 +        "@ExpectedBase(value=Foo.class, "
   2.819 +                + "getAnnotationVal = \"Foo\", "
   2.820 +                + "getAnnotationsVals = {"
   2.821 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.822 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
   2.823 +                + "getDeclAnnoVal = \"Foo\","
   2.824 +                + "getAnnosArgs = {\"Foo\"},"
   2.825 +                + "getDeclAnnosArgs = {\"Foo\"})",
   2.826 +        "@ExpectedContainer(value=FooContainer.class, "
   2.827 +                + "getAnnotationVal = \"FooContainer\", "
   2.828 +                + "getAnnotationsVals = {"
   2.829 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.830 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
   2.831 +                + "getDeclAnnoVal = \"NULL\","
   2.832 +                + "getAnnosArgs = {\"FooContainer\"},"
   2.833 +                + "getDeclAnnosArgs = {})") {
   2.834 +
   2.835 +            @Override
   2.836 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.837 +                    String className) {
   2.838 +                String anno = "";
   2.839 +                String replaceVal = "";
   2.840 +                String contents = "";
   2.841 +                JavaFileObject srcFileObj = null;
   2.842 +                Iterable<? extends JavaFileObject> files = null;
   2.843 +
   2.844 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.845 +                        + getExpectedContainer() + "\n";
   2.846 +                StringBuilder commonStmts = getCommonStmts(false);
   2.847 +
   2.848 +                /*
   2.849 +                Sample testSrc:
   2.850 +                @Retention(RetentionPolicy.RUNTIME)
   2.851 +                @Inherited
   2.852 +                @interface Foo {}
   2.853 +
   2.854 +                @Retention(RetentionPolicy.RUNTIME)
   2.855 +                @Inherited
   2.856 +                @interface FooContainer {
   2.857 +                Foo[] value();
   2.858 +                }
   2.859 +
   2.860 +                @FooContainer(value = {@Foo, @Foo}) @Foo
   2.861 +                class SuperClass { }
   2.862 +
   2.863 +                @ExpectedBase
   2.864 +                @ExpectedContainer
   2.865 +                @Foo
   2.866 +                class SubClass extends SuperClass {}
   2.867 +                 */
   2.868 +                // @Inherited only works for classes, no switch cases for
   2.869 +                // method, field, package
   2.870 +
   2.871 +                if (srcType == SrcType.CLASS) {
   2.872 +                    // Contents for SuperClass
   2.873 +                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
   2.874 +                            + Helper.ContentVars.BASEANNO.getVal();
   2.875 +                    replaceVal = commonStmts + "\n" + anno;
   2.876 +                    String superClassContents = srcType.getTemplate()
   2.877 +                            .replace("#CN", SUPERCLASS)
   2.878 +                            .replace("#REPLACE", replaceVal);
   2.879 +
   2.880 +                    // Contents for SubClass that extends SuperClass
   2.881 +                    anno = Helper.ContentVars.BASEANNO.getVal();
   2.882 +                    replaceVal = expectedVals + "\n" + anno;
   2.883 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
   2.884 +                            .replace("#CN", className).replace("#SN", SUPERCLASS)
   2.885 +                            .replace("#REPLACE", replaceVal);
   2.886 +
   2.887 +                    contents = superClassContents + subClassContents;
   2.888 +                    srcFileObj = Helper.getFile(className, contents);
   2.889 +                    files = Arrays.asList(srcFileObj);
   2.890 +                }
   2.891 +                return files;
   2.892 +            }
   2.893 +        },
   2.894 +        SingleOnSuperContainerOnSub_Inherited_Legacy(
   2.895 +        "@ExpectedBase(value=Foo.class, "
   2.896 +                + "getAnnotationVal = \"Foo\", "
   2.897 +                + "getAnnotationsVals = {"
   2.898 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.899 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
   2.900 +                + "getDeclAnnoVal = \"NULL\","
   2.901 +                + "getAnnosArgs = {\"Foo\"},"
   2.902 +                + "getDeclAnnosArgs = {})",
   2.903 +        "@ExpectedContainer(value=FooContainer.class, "
   2.904 +                + "getAnnotationVal = \"FooContainer\", "
   2.905 +                + "getAnnotationsVals = {"
   2.906 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.907 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
   2.908 +                + "getDeclAnnoVal = \"FooContainer\","
   2.909 +                + "getAnnosArgs = {\"FooContainer\"},"
   2.910 +                + "getDeclAnnosArgs = {\"FooContainer\"})") {
   2.911 +
   2.912 +            @Override
   2.913 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.914 +                    String className) {
   2.915 +                String anno = "";
   2.916 +                String replaceVal = "";
   2.917 +                String contents = "";
   2.918 +
   2.919 +                JavaFileObject srcFileObj = null;
   2.920 +                Iterable<? extends JavaFileObject> files = null;
   2.921 +
   2.922 +                String expectedVals = "\n" + getExpectedBase() + "\n"
   2.923 +                        + getExpectedContainer() + "\n";
   2.924 +                StringBuilder commonStmts = getCommonStmts(false);
   2.925 +
   2.926 +                /*
   2.927 +                Sample testSrc:
   2.928 +                @Retention(RetentionPolicy.RUNTIME)
   2.929 +                @Inherited
   2.930 +                @interface Foo {}
   2.931 +
   2.932 +                @Retention(RetentionPolicy.RUNTIME)
   2.933 +                @Inherited
   2.934 +                @interface FooContainer {
   2.935 +                Foo[] value();
   2.936 +                }
   2.937 +
   2.938 +                @Foo
   2.939 +                class SuperClass { }
   2.940 +
   2.941 +                @ExpectedBase
   2.942 +                @ExpectedContainer
   2.943 +                @FooContainer(value = {@Foo, @Foo})
   2.944 +                class SubClass extends SuperClass {}
   2.945 +                 */
   2.946 +
   2.947 +                if (srcType == SrcType.CLASS) {
   2.948 +                    //Contents for SuperClass
   2.949 +                    anno = Helper.ContentVars.BASEANNO.getVal();
   2.950 +                    replaceVal = commonStmts + "\n" + anno;
   2.951 +                    String superClassContents = srcType.getTemplate()
   2.952 +                            .replace("#CN", SUPERCLASS)
   2.953 +                            .replace("#REPLACE", replaceVal);
   2.954 +
   2.955 +                    //Contents for SubClass that extends SuperClass
   2.956 +                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
   2.957 +                    replaceVal = expectedVals + "\n" + anno;
   2.958 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
   2.959 +                            .replace("#CN", className).replace("#SN", SUPERCLASS)
   2.960 +                            .replace("#REPLACE", replaceVal);
   2.961 +
   2.962 +                    contents = superClassContents + subClassContents;
   2.963 +                    srcFileObj = Helper.getFile(className, contents);
   2.964 +                    files = Arrays.asList(srcFileObj);
   2.965 +                }
   2.966 +                return files;
   2.967 +            }
   2.968 +        },
   2.969 +        SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy(
   2.970 +        "@ExpectedBase(value=Foo.class, "
   2.971 +                + "getAnnotationVal = \"Foo\", "
   2.972 +                + "getAnnotationsVals = {"
   2.973 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.974 +                + "getDeclAnnosVals = {"
   2.975 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
   2.976 +                + "getDeclAnnoVal = \"Foo\","
   2.977 +                + "getAnnosArgs = {\"Foo\"},"
   2.978 +                + "getDeclAnnosArgs = {\"Foo\"})",
   2.979 +        "@ExpectedContainer(value=FooContainer.class, "
   2.980 +                + "getAnnotationVal = \"FooContainer\", "
   2.981 +                + "getAnnotationsVals = {"
   2.982 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
   2.983 +                + "getDeclAnnosVals = {"
   2.984 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
   2.985 +                + "getDeclAnnoVal = \"FooContainer\","
   2.986 +                + "getAnnosArgs = {\"FooContainer\"},"
   2.987 +                + "getDeclAnnosArgs = {\"FooContainer\"})") {
   2.988 +
   2.989 +            @Override
   2.990 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
   2.991 +                    String className) {
   2.992 +                String anno = "";
   2.993 +                String replaceVal = "";
   2.994 +                String contents = "";
   2.995 +
   2.996 +                JavaFileObject srcFileObj = null;
   2.997 +                Iterable<? extends JavaFileObject> files = null;
   2.998 +
   2.999 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1000 +                        + getExpectedContainer() + "\n";
  2.1001 +                StringBuilder commonStmts = getCommonStmts(false);
  2.1002 +
  2.1003 +                /*
  2.1004 +                Sample testSrc:
  2.1005 +                @Retention(RetentionPolicy.RUNTIME)
  2.1006 +                @Inherited
  2.1007 +                @interface Foo {}
  2.1008 +
  2.1009 +                @Retention(RetentionPolicy.RUNTIME)
  2.1010 +                @Inherited
  2.1011 +                @interface FooContainer {
  2.1012 +                Foo[] value();
  2.1013 +                }
  2.1014 +
  2.1015 +                @Foo
  2.1016 +                class SuperClass { }
  2.1017 +
  2.1018 +                @ExpectedBase
  2.1019 +                @ExpectedContainer
  2.1020 +                @FooContainer(value = {@Foo, @Foo}) @Foo
  2.1021 +                class SubClass extends SuperClass {}
  2.1022 +                 */
  2.1023 +
  2.1024 +                if (srcType == SrcType.CLASS) {
  2.1025 +                    //Contents for SuperClass
  2.1026 +                    anno = Helper.ContentVars.BASEANNO.getVal();
  2.1027 +                    replaceVal = commonStmts + "\n" + anno;
  2.1028 +                    String superClassContents = srcType.getTemplate()
  2.1029 +                            .replace("#CN", SUPERCLASS)
  2.1030 +                            .replace("#REPLACE", replaceVal);
  2.1031 +
  2.1032 +                    //Contents for SubClass that extends SuperClass
  2.1033 +                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
  2.1034 +                            + Helper.ContentVars.BASEANNO.getVal();
  2.1035 +                    replaceVal = expectedVals + "\n" + anno;
  2.1036 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1037 +                            .replace("#CN", className).replace("#SN", SUPERCLASS)
  2.1038 +                            .replace("#REPLACE", replaceVal);
  2.1039 +
  2.1040 +                    contents = superClassContents + subClassContents;
  2.1041 +                    srcFileObj = Helper.getFile(className, contents);
  2.1042 +                    files = Arrays.asList(srcFileObj);
  2.1043 +                }
  2.1044 +                return files;
  2.1045 +            }
  2.1046 +        },
  2.1047 +        BasicRepeatable(
  2.1048 +        "@ExpectedBase(value=Foo.class, "
  2.1049 +                + "getAnnotationVal = \"NULL\", "
  2.1050 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\" }, "
  2.1051 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
  2.1052 +                + "getDeclAnnoVal = \"NULL\","
  2.1053 +                + "getAnnosArgs = {\"Foo\", \"Foo\"},"
  2.1054 +                + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
  2.1055 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1056 +                + "getAnnotationVal = \"FooContainer\","
  2.1057 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
  2.1058 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1059 +                + "getDeclAnnoVal = \"FooContainer\","
  2.1060 +                + "getAnnosArgs = {\"FooContainer\"},"
  2.1061 +                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
  2.1062 +
  2.1063 +            @Override
  2.1064 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1065 +                    String className) {
  2.1066 +                String anno = "";
  2.1067 +                String replaceVal = "";
  2.1068 +                String testSrc = "";
  2.1069 +                String pkgInfoContents = "";
  2.1070 +                String contents = "";
  2.1071 +
  2.1072 +                JavaFileObject pkgFileObj = null;
  2.1073 +                JavaFileObject srcFileObj = null;
  2.1074 +                Iterable<? extends JavaFileObject> files = null;
  2.1075 +
  2.1076 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1077 +                        + getExpectedContainer() + "\n";
  2.1078 +                StringBuilder commonStmts = new StringBuilder();
  2.1079 +
  2.1080 +                anno = Helper.ContentVars.REPEATABLEANNO.getVal();
  2.1081 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
  2.1082 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
  2.1083 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.1084 +                        .append(Helper.ContentVars.REPEATABLE.getVal())
  2.1085 +                        .append(Helper.ContentVars.BASE.getVal())
  2.1086 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.1087 +                        .append(Helper.ContentVars.CONTAINER.getVal());
  2.1088 +                switch (srcType) {
  2.1089 +                    case PACKAGE:
  2.1090 +                        /*
  2.1091 +                        Sample package-info.java
  2.1092 +                        @ExpectedBase
  2.1093 +                        @ExpectedContainer
  2.1094 +                        @Foo() @Foo()
  2.1095 +                        package testpkg;
  2.1096 +
  2.1097 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1098 +                        @Repeatable(FooContainer.class)
  2.1099 +                        @interface Foo {}
  2.1100 +
  2.1101 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1102 +                        @interface FooContainer {
  2.1103 +                        Foo[] value();
  2.1104 +                        }
  2.1105 +
  2.1106 +                        Sample testSrc:
  2.1107 +                        package testpkg;
  2.1108 +                        class A {}
  2.1109 +                         */
  2.1110 +                        testSrc = srcType.getTemplate().replace("#CN", className);
  2.1111 +                        contents = testSrc;
  2.1112 +                        srcFileObj = Helper.getFile(className, contents);
  2.1113 +
  2.1114 +                        replaceVal = expectedVals + "\n" + anno;
  2.1115 +                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
  2.1116 +                                .replace("#REPLACE1", replaceVal)
  2.1117 +                                .replace("#REPLACE2", commonStmts);
  2.1118 +                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
  2.1119 +                        files = Arrays.asList(pkgFileObj, srcFileObj);
  2.1120 +                        break;
  2.1121 +                    default:
  2.1122 +                        /*
  2.1123 +                        Sample testSrc for class:
  2.1124 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1125 +                        @Repeatable(FooContainer.class)
  2.1126 +                        @interface Foo {}
  2.1127 +
  2.1128 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1129 +                        @interface FooContainer {
  2.1130 +                        Foo[] value();
  2.1131 +                        }
  2.1132 +
  2.1133 +                        @ExpectedBase
  2.1134 +                        @ExpectedContainer
  2.1135 +                        @Foo @Foo
  2.1136 +                        class A { }
  2.1137 +                         */
  2.1138 +                        replaceVal = expectedVals + anno;
  2.1139 +                        testSrc = srcType.getTemplate().replace("#CN", className)
  2.1140 +                                .replace("#REPLACE", replaceVal);
  2.1141 +                        contents = commonStmts + testSrc;
  2.1142 +                        srcFileObj = Helper.getFile(className, contents);
  2.1143 +                        files = Arrays.asList(srcFileObj);
  2.1144 +                }
  2.1145 +                return files;
  2.1146 +            }
  2.1147 +        },
  2.1148 +        BasicContainerRepeatable(
  2.1149 +        "@ExpectedBase(value=Foo.class, "
  2.1150 +                + "getAnnotationVal = \"NULL\", "
  2.1151 +                + "getAnnotationsVals = {"
  2.1152 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1153 +                + "getDeclAnnosVals = {"
  2.1154 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
  2.1155 +                + "getDeclAnnoVal = \"NULL\","
  2.1156 +                + "getAnnosArgs = {\"Foo\", \"Foo\"},"
  2.1157 +                + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
  2.1158 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1159 +                + "getAnnotationVal = \"FooContainer\","
  2.1160 +                + "getAnnotationsVals = {"
  2.1161 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
  2.1162 +                + "getDeclAnnosVals = {"
  2.1163 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1164 +                + "getDeclAnnoVal = \"FooContainer\","
  2.1165 +                + "getAnnosArgs = {\"FooContainer\"},"
  2.1166 +                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
  2.1167 +
  2.1168 +            @Override
  2.1169 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1170 +                    String className) {
  2.1171 +                String anno = "";
  2.1172 +                String replaceVal = "";
  2.1173 +                String testSrc = "";
  2.1174 +                String pkgInfoContents = "";
  2.1175 +                String contents = "";
  2.1176 +
  2.1177 +                JavaFileObject pkgFileObj = null;
  2.1178 +                JavaFileObject srcFileObj = null;
  2.1179 +                Iterable<? extends JavaFileObject> files = null;
  2.1180 +
  2.1181 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1182 +                        + getExpectedContainer() + "\n";
  2.1183 +                StringBuilder commonStmts = new StringBuilder();
  2.1184 +
  2.1185 +                anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
  2.1186 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
  2.1187 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
  2.1188 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.1189 +                        .append(Helper.ContentVars.REPEATABLE.getVal())
  2.1190 +                        .append(Helper.ContentVars.BASE.getVal())
  2.1191 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.1192 +                        .append(Helper.ContentVars.CONTAINER.getVal());
  2.1193 +                switch (srcType) {
  2.1194 +                    case PACKAGE:
  2.1195 +                        /*
  2.1196 +                        Sample package-info.java
  2.1197 +                        @ExpectedBase
  2.1198 +                        @ExpectedContainer
  2.1199 +                        @FooContainer(value = {@Foo, @Foo})
  2.1200 +                        package testpkg;
  2.1201 +
  2.1202 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1203 +                        @Repeatable(FooContainer.class)
  2.1204 +                        @interface Foo {}
  2.1205 +
  2.1206 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1207 +                        @interface FooContainer {
  2.1208 +                        Foo[] value();
  2.1209 +                        }
  2.1210 +
  2.1211 +                        Sample testSrc:
  2.1212 +                        package testpkg;
  2.1213 +                        class A {}
  2.1214 +                         */
  2.1215 +                        testSrc = srcType.getTemplate().replace("#CN", className);
  2.1216 +                        contents = testSrc;
  2.1217 +                        srcFileObj = Helper.getFile(className, contents);
  2.1218 +
  2.1219 +                        replaceVal = expectedVals + "\n" + anno;
  2.1220 +                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
  2.1221 +                                .replace("#REPLACE1", replaceVal)
  2.1222 +                                .replace("#REPLACE2", commonStmts);
  2.1223 +                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
  2.1224 +                        files = Arrays.asList(pkgFileObj, srcFileObj);
  2.1225 +                        break;
  2.1226 +                    default:
  2.1227 +                        /*
  2.1228 +                        Sample testSrc for class:
  2.1229 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1230 +                        @Repeatable(FooContainer.class)
  2.1231 +                        @interface Foo {}
  2.1232 +
  2.1233 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1234 +                        @interface FooContainer {
  2.1235 +                        Foo[] value();
  2.1236 +                        }
  2.1237 +
  2.1238 +                        @ExpectedBase
  2.1239 +                        @ExpectedContainer
  2.1240 +                        @FooContainer(value = {@Foo, @Foo})
  2.1241 +                        class A { }
  2.1242 +                         */
  2.1243 +                        replaceVal = expectedVals + anno;
  2.1244 +                        testSrc = srcType.getTemplate().replace("#CN", className)
  2.1245 +                                .replace("#REPLACE", replaceVal);
  2.1246 +                        contents = commonStmts + testSrc;
  2.1247 +                        srcFileObj = Helper.getFile(className, contents);
  2.1248 +                        files = Arrays.asList(srcFileObj);
  2.1249 +                }
  2.1250 +                return files;
  2.1251 +            }
  2.1252 +        },
  2.1253 +        BasicContainerRepeatable_Inherited(
  2.1254 +        "@ExpectedBase(value=Foo.class, "
  2.1255 +                + "getAnnotationVal = \"NULL\", "
  2.1256 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1257 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
  2.1258 +                + "getDeclAnnoVal = \"NULL\", "
  2.1259 +                + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
  2.1260 +                + "getDeclAnnosArgs = {})",
  2.1261 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1262 +                + "getAnnotationVal = \"FooContainer\", "
  2.1263 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1264 +                + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, "
  2.1265 +                + "getDeclAnnoVal = \"NULL\", "
  2.1266 +                + "getAnnosArgs = {\"FooContainer\"}, "
  2.1267 +                + "getDeclAnnosArgs = {})") {
  2.1268 +
  2.1269 +            @Override
  2.1270 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1271 +                    String className) {
  2.1272 +                String anno = "";
  2.1273 +                String replaceVal = "";
  2.1274 +                String contents = "";
  2.1275 +                JavaFileObject srcFileObj = null;
  2.1276 +                Iterable<? extends JavaFileObject> files = null;
  2.1277 +
  2.1278 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1279 +                        + getExpectedContainer() + "\n";
  2.1280 +                StringBuilder commonStmts = getCommonStmts(true);
  2.1281 +                /*
  2.1282 +                Sample testSrc:
  2.1283 +                @Retention(RetentionPolicy.RUNTIME)
  2.1284 +                @Inherited
  2.1285 +                @Repeatable(FooContainer.class)
  2.1286 +                @interface Foo {}
  2.1287 +
  2.1288 +                @Retention(RetentionPolicy.RUNTIME)
  2.1289 +                @Inherited
  2.1290 +                @interface FooContainer {
  2.1291 +                Foo[] value();
  2.1292 +                }
  2.1293 +
  2.1294 +                @FooContainer(value = {@Foo, @Foo})
  2.1295 +                class SuperClass { }
  2.1296 +
  2.1297 +                @ExpectedBase
  2.1298 +                @ExpectedContainer
  2.1299 +                class SubClass extends SuperClass { }
  2.1300 +                 */
  2.1301 +                // @Inherited only works for classes, no switch cases for
  2.1302 +                // method, field, package
  2.1303 +                anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
  2.1304 +
  2.1305 +                if (srcType == SrcType.CLASS) {
  2.1306 +                    // Contents for SuperClass
  2.1307 +                    replaceVal = commonStmts + "\n" + anno;
  2.1308 +                    String superClassContents = srcType.getTemplate()
  2.1309 +                            .replace("#CN", SUPERCLASS)
  2.1310 +                            .replace("#REPLACE", replaceVal);
  2.1311 +
  2.1312 +                    // Contents for SubClass that extends SuperClass
  2.1313 +                    replaceVal = expectedVals;
  2.1314 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1315 +                            .replace("#CN", className)
  2.1316 +                            .replace("#SN", SUPERCLASS)
  2.1317 +                            .replace("#REPLACE", replaceVal);
  2.1318 +
  2.1319 +                    contents = superClassContents + subClassContents;
  2.1320 +                    srcFileObj = Helper.getFile(className, contents);
  2.1321 +                    files = Arrays.asList(srcFileObj);
  2.1322 +                }
  2.1323 +                return files;
  2.1324 +            }
  2.1325 +        },
  2.1326 +        RepeatableAnnoInherited(
  2.1327 +        "@ExpectedBase(value=Foo.class, "
  2.1328 +                + "getAnnotationVal = \"NULL\", "
  2.1329 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1330 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
  2.1331 +                + // ignores inherited annotations
  2.1332 +                "getDeclAnnoVal = \"NULL\", "
  2.1333 +                + // ignores inherited
  2.1334 +                "getAnnosArgs = {\"Foo\", \"Foo\"}, "
  2.1335 +                + "getDeclAnnosArgs = {})", // ignores inherited
  2.1336 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1337 +                + "getAnnotationVal = \"FooContainer\", "
  2.1338 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1339 +                + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, "
  2.1340 +                + // ignores inherited annotations
  2.1341 +                "getDeclAnnoVal = \"NULL\", "
  2.1342 +                + // ignores inherited
  2.1343 +                "getAnnosArgs = {\"FooContainer\"}, "
  2.1344 +                + "getDeclAnnosArgs = {})") { // ignores inherited
  2.1345 +
  2.1346 +            @Override
  2.1347 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1348 +                    String className) {
  2.1349 +                String anno = "";
  2.1350 +                String replaceVal = "";
  2.1351 +                String contents = "";
  2.1352 +                JavaFileObject srcFileObj = null;
  2.1353 +                Iterable<? extends JavaFileObject> files = null;
  2.1354 +
  2.1355 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1356 +                        + getExpectedContainer() + "\n";
  2.1357 +                StringBuilder commonStmts = getCommonStmts(true);
  2.1358 +                /*
  2.1359 +                Sample testSrc:
  2.1360 +                @Retention(RetentionPolicy.RUNTIME)
  2.1361 +                @Inherited
  2.1362 +                @Repeatable(FooContainer.class)
  2.1363 +                @interface Foo {}
  2.1364 +
  2.1365 +                @Retention(RetentionPolicy.RUNTIME)
  2.1366 +                @Inherited
  2.1367 +                @interface FooContainer {
  2.1368 +                Foo[] value();
  2.1369 +                }
  2.1370 +
  2.1371 +                @Foo() @Foo()
  2.1372 +                class SuperClass { }
  2.1373 +
  2.1374 +                @ExpectedBase
  2.1375 +                @ExpectedContainer
  2.1376 +                class SubClass extends SuperClass { }
  2.1377 +                 */
  2.1378 +                // @Inherited only works for classes, no switch cases for
  2.1379 +                // method, field, package
  2.1380 +                anno = Helper.ContentVars.REPEATABLEANNO.getVal();
  2.1381 +
  2.1382 +                if (srcType == SrcType.CLASS) {
  2.1383 +                    // Contents for SuperClass
  2.1384 +                    replaceVal = commonStmts + "\n" + anno;
  2.1385 +                    String superClassContents = srcType.getTemplate()
  2.1386 +                            .replace("#CN", SUPERCLASS)
  2.1387 +                            .replace("#REPLACE", replaceVal);
  2.1388 +
  2.1389 +                    // Contents for SubClass that extends SuperClass
  2.1390 +                    replaceVal = expectedVals;
  2.1391 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1392 +                            .replace("#CN", className)
  2.1393 +                            .replace("#SN", SUPERCLASS)
  2.1394 +                            .replace("#REPLACE", replaceVal);
  2.1395 +
  2.1396 +                    contents = superClassContents + subClassContents;
  2.1397 +                    srcFileObj = Helper.getFile(className, contents);
  2.1398 +                    files = Arrays.asList(srcFileObj);
  2.1399 +                }
  2.1400 +                return files;
  2.1401 +            }
  2.1402 +        },
  2.1403 +        SingleAnnoWithContainer(
  2.1404 +        "@ExpectedBase(value=Foo.class, "
  2.1405 +                + "getAnnotationVal = \"Foo\", "
  2.1406 +                + "getAnnotationsVals = {"
  2.1407 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
  2.1408 +                + "getDeclAnnosVals = {"
  2.1409 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
  2.1410 +                + "getDeclAnnoVal = \"Foo\","
  2.1411 +                + "getAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"},"
  2.1412 +                + "getDeclAnnosArgs = {\"Foo\", \"Foo\",\"Foo\"})",
  2.1413 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1414 +                + "getAnnotationVal = \"FooContainer\", "
  2.1415 +                + "getAnnotationsVals = {"
  2.1416 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
  2.1417 +                + "getDeclAnnosVals = {"
  2.1418 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1419 +                + "getDeclAnnoVal = \"FooContainer\","
  2.1420 +                + "getDeclAnnosArgs = {\"FooContainer\"},"
  2.1421 +                + "getAnnosArgs = {\"FooContainer\"})") {
  2.1422 +
  2.1423 +            @Override
  2.1424 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1425 +                    String className) {
  2.1426 +                String anno = "";
  2.1427 +                String replaceVal = "";
  2.1428 +                String testSrc = "";
  2.1429 +                String pkgInfoContents = "";
  2.1430 +                String contents = "";
  2.1431 +
  2.1432 +                JavaFileObject pkgFileObj = null;
  2.1433 +                JavaFileObject srcFileObj = null;
  2.1434 +                Iterable<? extends JavaFileObject> files = null;
  2.1435 +
  2.1436 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1437 +                        + getExpectedContainer() + "\n";
  2.1438 +                StringBuilder commonStmts = new StringBuilder();
  2.1439 +
  2.1440 +                anno = Helper.ContentVars.BASEANNO.getVal() + " "
  2.1441 +                        + Helper.ContentVars.LEGACYCONTAINER.getVal();
  2.1442 +                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
  2.1443 +                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
  2.1444 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.1445 +                        .append(Helper.ContentVars.REPEATABLE.getVal())
  2.1446 +                        .append(Helper.ContentVars.BASE.getVal())
  2.1447 +                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.1448 +                        .append(Helper.ContentVars.CONTAINER.getVal());
  2.1449 +                switch (srcType) {
  2.1450 +                    case PACKAGE:
  2.1451 +                        /*
  2.1452 +                        Sample package-info.java
  2.1453 +                        @ExpectedBase
  2.1454 +                        @ExpectedContainer
  2.1455 +                        @Foo @FooContainer(value = {@Foo, @Foo})
  2.1456 +                        package testpkg;
  2.1457 +
  2.1458 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1459 +                        @Repeatable(FooContainer.class)
  2.1460 +                        @interface Foo {}
  2.1461 +
  2.1462 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1463 +                        @interface FooContainer {
  2.1464 +                        Foo[] value();
  2.1465 +                        }
  2.1466 +
  2.1467 +                        Sample testSrc:
  2.1468 +                        package testpkg;
  2.1469 +                        class A {}
  2.1470 +                         */
  2.1471 +                        testSrc = srcType.getTemplate().replace("#CN", className);
  2.1472 +                        contents = testSrc;
  2.1473 +                        srcFileObj = Helper.getFile(className, contents);
  2.1474 +
  2.1475 +                        replaceVal = expectedVals + "\n" + anno;
  2.1476 +                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
  2.1477 +                                .replace("#REPLACE1", replaceVal)
  2.1478 +                                .replace("#REPLACE2", commonStmts);
  2.1479 +                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
  2.1480 +                        files = Arrays.asList(pkgFileObj, srcFileObj);
  2.1481 +                        break;
  2.1482 +                    default:
  2.1483 +                        /*
  2.1484 +                        Sample testSrc:
  2.1485 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1486 +                        @Inherited
  2.1487 +                        @Repeatable(FooContainer.class)
  2.1488 +                        @interface Foo {}
  2.1489 +
  2.1490 +                        @Retention(RetentionPolicy.RUNTIME)
  2.1491 +                        @Inherited
  2.1492 +                        @interface FooContainer {
  2.1493 +                        Foo[] value();
  2.1494 +                        }
  2.1495 +
  2.1496 +                        @ExpectedBase
  2.1497 +                        @ExpectedContainer
  2.1498 +                        @Foo @FooContainer(value = {@Foo, @Foo})
  2.1499 +                        class A { }
  2.1500 +                         */
  2.1501 +                        replaceVal = expectedVals + anno;
  2.1502 +                        testSrc = srcType.getTemplate()
  2.1503 +                                .replace("#CN", className)
  2.1504 +                                .replace("#REPLACE", replaceVal);
  2.1505 +                        contents = commonStmts + testSrc;
  2.1506 +                        srcFileObj = Helper.getFile(className, contents);
  2.1507 +                        files = Arrays.asList(srcFileObj);
  2.1508 +                }
  2.1509 +                return files;
  2.1510 +            }
  2.1511 +        },
  2.1512 +        AnnoOnSuperAndSubClass_Inherited(
  2.1513 +        "@ExpectedBase(value=Foo.class, "
  2.1514 +                + "getAnnotationVal = \"Foo\", "
  2.1515 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\" }, "
  2.1516 +                + // override every annotation on superClass
  2.1517 +                "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
  2.1518 +                + // ignores inherited annotations
  2.1519 +                "getDeclAnnoVal = \"Foo\", " // ignores inherited
  2.1520 +                + "getAnnosArgs = {\"Foo\"}, "
  2.1521 +                + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
  2.1522 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1523 +                + "getAnnotationVal = \"NULL\", "
  2.1524 +                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\" }, "
  2.1525 +                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
  2.1526 +                + // ignores inherited annotations
  2.1527 +                "getDeclAnnoVal = \"NULL\", " + // ignores inherited
  2.1528 +                "getAnnosArgs = {}, " + "getDeclAnnosArgs = {})") {
  2.1529 +
  2.1530 +            @Override
  2.1531 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1532 +                    String className) {
  2.1533 +                String anno = "";
  2.1534 +                String replaceVal = "";
  2.1535 +                String contents = "";
  2.1536 +                JavaFileObject srcFileObj = null;
  2.1537 +                Iterable<? extends JavaFileObject> files = null;
  2.1538 +
  2.1539 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1540 +                        + getExpectedContainer() + "\n";
  2.1541 +                StringBuilder commonStmts = getCommonStmts(true);
  2.1542 +
  2.1543 +                /*
  2.1544 +                Sample testSrc:
  2.1545 +                @Retention(RetentionPolicy.RUNTIME)
  2.1546 +                @Inherited
  2.1547 +                @Repeatable(FooContainer.class)
  2.1548 +                @interface Foo {}
  2.1549 +
  2.1550 +                @Retention(RetentionPolicy.RUNTIME)
  2.1551 +                @Inherited
  2.1552 +                @interface FooContainer {
  2.1553 +                Foo[] value();
  2.1554 +                }
  2.1555 +
  2.1556 +                @Foo()
  2.1557 +                class SuperClass { }
  2.1558 +
  2.1559 +                @ExpectedBase
  2.1560 +                @ExpectedContainer
  2.1561 +                @Foo
  2.1562 +                class SubClass extends SuperClass { }
  2.1563 +                 */
  2.1564 +                // @Inherited only works for classes, no switch cases for
  2.1565 +                // method, field, package
  2.1566 +
  2.1567 +                if (srcType == SrcType.CLASS) {
  2.1568 +                    // Contents for SuperClass
  2.1569 +                    anno = Helper.ContentVars.BASEANNO.getVal();
  2.1570 +                    replaceVal = commonStmts + "\n" + anno;
  2.1571 +                    String superClassContents = srcType.getTemplate()
  2.1572 +                            .replace("#CN", SUPERCLASS)
  2.1573 +                            .replace("#REPLACE", replaceVal);
  2.1574 +
  2.1575 +                    // Contents for SubClass that extends SuperClass
  2.1576 +                    replaceVal = expectedVals + "\n" + anno;
  2.1577 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1578 +                            .replace("#CN", className)
  2.1579 +                            .replace("#SN", SUPERCLASS)
  2.1580 +                            .replace("#REPLACE", replaceVal);
  2.1581 +
  2.1582 +                    contents = superClassContents + subClassContents;
  2.1583 +                    srcFileObj = Helper.getFile(className, contents);
  2.1584 +                    files = Arrays.asList(srcFileObj);
  2.1585 +                }
  2.1586 +                return files;
  2.1587 +            }
  2.1588 +        },
  2.1589 +//         // Testcase not working as expected, JDK-8004912
  2.1590 +//         RepeatableOnSuperSingleOnSub_Inherited(
  2.1591 +//         "@ExpectedBase(value=Foo.class, "
  2.1592 +//                 + "getAnnotationVal = \"Foo\", "
  2.1593 +//                 + "getAnnotationsVals = {"
  2.1594 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1595 +//                 + //override every annotation on superClass
  2.1596 +//                 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
  2.1597 +//                 + // ignores inherited annotations
  2.1598 +//                 "getDeclAnnoVal = \"Foo\", " // ignores inherited
  2.1599 +//                 + "getAnnosArgs = {\"Foo\"}, "
  2.1600 +//                 + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
  2.1601 +//         "@ExpectedContainer(value=FooContainer.class, "
  2.1602 +//                 + "getAnnotationVal = \"FooContainer\", "
  2.1603 +//                 + "getAnnotationsVals = {"
  2.1604 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1605 +//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
  2.1606 +//                 + // ignores inherited annotations
  2.1607 +//                 "getDeclAnnoVal = \"NULL\", "
  2.1608 +//                 + "getAnnosArgs = {\"FooContainer\"}, "
  2.1609 +//                 + "getDeclAnnosArgs = {}) // ignores inherited ") {
  2.1610 +
  2.1611 +//             @Override
  2.1612 +//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1613 +//                     String className) {
  2.1614 +//                 String anno = "";
  2.1615 +//                 String replaceVal = "";
  2.1616 +//                 String contents = "";
  2.1617 +//                 JavaFileObject srcFileObj = null;
  2.1618 +//                 Iterable<? extends JavaFileObject> files = null;
  2.1619 +
  2.1620 +//                 String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1621 +//                         + getExpectedContainer() + "\n";
  2.1622 +//                 StringBuilder commonStmts = getCommonStmts(true);
  2.1623 +
  2.1624 +//                 /*
  2.1625 +//                 Sample testSrc:
  2.1626 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1627 +//                 @Inherited
  2.1628 +//                 @Repeatable(FooContainer.class)
  2.1629 +//                 @interface Foo {}
  2.1630 +
  2.1631 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1632 +//                 @Inherited
  2.1633 +//                 @interface FooContainer {
  2.1634 +//                 Foo[] value();
  2.1635 +//                 }
  2.1636 +
  2.1637 +//                 @Foo() @Foo
  2.1638 +//                 class SuperClass { }
  2.1639 +
  2.1640 +//                 @ExpectedBase
  2.1641 +//                 @ExpectedContainer
  2.1642 +//                 @Foo
  2.1643 +//                 class SubClass extends SuperClass { }
  2.1644 +//                  */
  2.1645 +//                 //@Inherited only works for classes, no switch cases for method, field, package
  2.1646 +
  2.1647 +//                 if (srcType == SrcType.CLASS) {
  2.1648 +//                     //Contents for SuperClass
  2.1649 +//                     anno = Helper.ContentVars.REPEATABLEANNO.getVal();
  2.1650 +//                     replaceVal = commonStmts + "\n" + anno;
  2.1651 +//                     String superClassContents = srcType.getTemplate()
  2.1652 +//                             .replace("#CN", SUPERCLASS)
  2.1653 +//                             .replace("#REPLACE", replaceVal);
  2.1654 +
  2.1655 +//                     //Contents for SubClass that extends SuperClass
  2.1656 +//                     anno = Helper.ContentVars.BASEANNO.getVal();
  2.1657 +//                     replaceVal = expectedVals + "\n" + anno;
  2.1658 +//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1659 +//                             .replace("#CN", className)
  2.1660 +//                             .replace("#SN", SUPERCLASS)
  2.1661 +//                             .replace("#REPLACE", replaceVal);
  2.1662 +//                     contents = superClassContents + subClassContents;
  2.1663 +//                     srcFileObj = Helper.getFile(className, contents);
  2.1664 +//                     files = Arrays.asList(srcFileObj);
  2.1665 +//                 }
  2.1666 +//                 return files;
  2.1667 +//             }
  2.1668 +//         },
  2.1669 +//         //Testcase not working as expected, JDK-8004912
  2.1670 +//         SingleOnSuperRepeatableOnSub_Inherited(
  2.1671 +//         "@ExpectedBase(value=Foo.class, "
  2.1672 +//                 + "getAnnotationVal = \"Foo\", "
  2.1673 +//                 + "getAnnotationsVals = {"
  2.1674 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1675 +//                 + //override every annotation on superClass
  2.1676 +//                 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1677 +//                 + // ignores inherited annotations
  2.1678 +//                 "getDeclAnnoVal = \"NULL\","// ignores inherited
  2.1679 +//                 + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
  2.1680 +//                 + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})",
  2.1681 +//         "@ExpectedContainer(value=FooContainer.class, "
  2.1682 +//                 + "getAnnotationVal = \"FooContainer\", "
  2.1683 +//                 + "getAnnotationsVals = {"
  2.1684 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1685 +//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
  2.1686 +//                 + // ignores inherited annotations
  2.1687 +//                 "getDeclAnnoVal = \"FooContainer\", "// ignores inherited
  2.1688 +//                 + "getAnnosArgs = {\"FooContainer\"}, "
  2.1689 +//                 + "getDeclAnnosArgs = {\"FooContainer\"})") {
  2.1690 +
  2.1691 +//             @Override
  2.1692 +//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1693 +//                     String className) {
  2.1694 +//                 String anno = "";
  2.1695 +//                 String replaceVal = "";
  2.1696 +//                 String contents = "";
  2.1697 +//                 JavaFileObject srcFileObj = null;
  2.1698 +//                 Iterable<? extends JavaFileObject> files = null;
  2.1699 +
  2.1700 +//                 String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1701 +//                         + getExpectedContainer() + "\n";
  2.1702 +//                 StringBuilder commonStmts = getCommonStmts(true);
  2.1703 +
  2.1704 +//                 /*
  2.1705 +//                 Sample testSrc:
  2.1706 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1707 +//                 @Inherited
  2.1708 +//                 @Repeatable(FooContainer.class)
  2.1709 +//                 @interface Foo {}
  2.1710 +
  2.1711 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1712 +//                 @Inherited
  2.1713 +//                 @interface FooContainer {
  2.1714 +//                 Foo[] value();
  2.1715 +//                 }
  2.1716 +
  2.1717 +//                 @Foo()
  2.1718 +//                 class SuperClass { }
  2.1719 +
  2.1720 +//                 @ExpectedBase
  2.1721 +//                 @ExpectedContainer
  2.1722 +//                 @Foo @Foo
  2.1723 +//                 class SubClass extends SuperClass { }
  2.1724 +//                  */
  2.1725 +
  2.1726 +//                 //@Inherited only works for classes, no switch cases for method, field, package
  2.1727 +//                 if (srcType == SrcType.CLASS) {
  2.1728 +//                     //Contents for SuperClass
  2.1729 +//                     anno = Helper.ContentVars.BASEANNO.getVal();
  2.1730 +//                     replaceVal = commonStmts + "\n" + anno;
  2.1731 +//                     String superClassContents = srcType.getTemplate()
  2.1732 +//                             .replace("#CN", SUPERCLASS)
  2.1733 +//                             .replace("#REPLACE", replaceVal);
  2.1734 +
  2.1735 +//                     //Contents for SubClass that extends SuperClass
  2.1736 +//                     anno = Helper.ContentVars.REPEATABLEANNO.getVal();
  2.1737 +//                     replaceVal = expectedVals + "\n" + anno;
  2.1738 +//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1739 +//                             .replace("#CN", className)
  2.1740 +//                             .replace("#SN", SUPERCLASS)
  2.1741 +//                             .replace("#REPLACE", replaceVal);
  2.1742 +
  2.1743 +//                     contents = superClassContents + subClassContents;
  2.1744 +//                     srcFileObj = Helper.getFile(className, contents);
  2.1745 +//                     files = Arrays.asList(srcFileObj);
  2.1746 +//                 }
  2.1747 +//                 return files;
  2.1748 +//             }
  2.1749 +//         },
  2.1750 +//         //Testcase not working as expected, JDK-8004912
  2.1751 +//         ContainerOnSuperSingleOnSub_Inherited(
  2.1752 +//         "@ExpectedBase(value=Foo.class, "
  2.1753 +//                 + "getAnnotationVal = \"Foo\", "
  2.1754 +//                 + "getAnnotationsVals = {"
  2.1755 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1756 +//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
  2.1757 +//                 + "getDeclAnnoVal = \"Foo\","
  2.1758 +//                 + "getAnnosArgs = {\"Foo\"},"
  2.1759 +//                 + "getDeclAnnosArgs = {\"Foo\"})",
  2.1760 +//         "@ExpectedContainer(value=FooContainer.class, "
  2.1761 +//                 + "getAnnotationVal = \"FooContainer\", "
  2.1762 +//                 + "getAnnotationsVals = {"
  2.1763 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1764 +//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
  2.1765 +//                 + "getDeclAnnoVal = \"NULL\","
  2.1766 +//                 + "getAnnosArgs = {\"FooContainer\"},"
  2.1767 +//                 + "getDeclAnnosArgs = {})") {
  2.1768 +
  2.1769 +//             @Override
  2.1770 +//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1771 +//                     String className) {
  2.1772 +//                 String anno = "";
  2.1773 +//                 String replaceVal = "";
  2.1774 +//                 String contents = "";
  2.1775 +//                 JavaFileObject srcFileObj = null;
  2.1776 +//                 Iterable<? extends JavaFileObject> files = null;
  2.1777 +
  2.1778 +//                 String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1779 +//                         + getExpectedContainer() + "\n";
  2.1780 +//                 StringBuilder commonStmts = getCommonStmts(true);
  2.1781 +
  2.1782 +//                 /*
  2.1783 +//                 Sample testSrc:
  2.1784 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1785 +//                 @Inherited
  2.1786 +//                 @Repeatable(FooContainer.class)
  2.1787 +//                 @interface Foo {}
  2.1788 +
  2.1789 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1790 +//                 @Inherited
  2.1791 +//                 @interface FooContainer {
  2.1792 +//                 Foo[] value();
  2.1793 +//                 }
  2.1794 +
  2.1795 +//                 @FooContainer(value = {@Foo, @Foo})
  2.1796 +//                 class SuperClass { }
  2.1797 +
  2.1798 +//                 @ExpectedBase
  2.1799 +//                 @ExpectedContainer
  2.1800 +//                 @Foo
  2.1801 +//                 class SubClass extends SuperClass { }
  2.1802 +//                  */
  2.1803 +
  2.1804 +//                 //@Inherited only works for classes, no switch cases for method, field, package
  2.1805 +//                 if (srcType == SrcType.CLASS) {
  2.1806 +//                     //Contents for SuperClass
  2.1807 +//                     anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
  2.1808 +//                     replaceVal = commonStmts + "\n" + anno;
  2.1809 +//                     String superClassContents = srcType.getTemplate()
  2.1810 +//                             .replace("#CN", SUPERCLASS)
  2.1811 +//                             .replace("#REPLACE", replaceVal);
  2.1812 +
  2.1813 +//                     //Contents for SubClass that extends SuperClass
  2.1814 +//                     anno = Helper.ContentVars.BASEANNO.getVal();
  2.1815 +//                     replaceVal = expectedVals + "\n" + anno;
  2.1816 +//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1817 +//                             .replace("#CN", className)
  2.1818 +//                             .replace("#SN", SUPERCLASS)
  2.1819 +//                             .replace("#REPLACE", replaceVal);
  2.1820 +
  2.1821 +//                     contents = superClassContents + subClassContents;
  2.1822 +//                     srcFileObj = Helper.getFile(className, contents);
  2.1823 +//                     files = Arrays.asList(srcFileObj);
  2.1824 +//                 }
  2.1825 +//                 return files;
  2.1826 +//             }
  2.1827 +//         },
  2.1828 +//         // TestCase not working as expected, JDK-8004912
  2.1829 +//         SingleOnSuperContainerOnSub_Inherited(
  2.1830 +//         "@ExpectedBase(value=Foo.class, "
  2.1831 +//                 + "getAnnotationVal = \"Foo\", "
  2.1832 +//                 + "getAnnotationsVals = {"
  2.1833 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1834 +//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
  2.1835 +//                 + "getDeclAnnoVal = \"NULL\","
  2.1836 +//                 + "getAnnosArgs = {\"Foo\", \"Foo\"},"
  2.1837 +//                 + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
  2.1838 +//         "@ExpectedContainer(value=FooContainer.class, "
  2.1839 +//                 + "getAnnotationVal = \"FooContainer\", "
  2.1840 +//                 + "getAnnotationsVals = {"
  2.1841 +//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1842 +//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
  2.1843 +//                 + "getDeclAnnoVal = \"FooContainer\","
  2.1844 +//                 + "getAnnosArgs = {\"FooContainer\"},"
  2.1845 +//                 + "getDeclAnnosArgs = {\"FooContainer\"})") {
  2.1846 +
  2.1847 +//             @Override
  2.1848 +//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1849 +//                     String className) {
  2.1850 +//                 String anno = "";
  2.1851 +//                 String replaceVal = "";
  2.1852 +//                 String contents = "";
  2.1853 +//                 JavaFileObject srcFileObj = null;
  2.1854 +//                 Iterable<? extends JavaFileObject> files = null;
  2.1855 +
  2.1856 +//                 String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1857 +//                         + getExpectedContainer() + "\n";
  2.1858 +//                 StringBuilder commonStmts = getCommonStmts(true);
  2.1859 +
  2.1860 +//                 /*
  2.1861 +//                 Sample testSrc:
  2.1862 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1863 +//                 @Inherited
  2.1864 +//                 @Repeatable(FooContainer.class)
  2.1865 +//                 @interface Foo {}
  2.1866 +
  2.1867 +//                 @Retention(RetentionPolicy.RUNTIME)
  2.1868 +//                 @Inherited
  2.1869 +//                 @interface FooContainer {
  2.1870 +//                 Foo[] value();
  2.1871 +//                 }
  2.1872 +
  2.1873 +//                 @Foo
  2.1874 +//                 class SuperClass { }
  2.1875 +
  2.1876 +//                 @ExpectedBase
  2.1877 +//                 @ExpectedContainer
  2.1878 +//                 @FooContainer(value = {@Foo, @Foo})
  2.1879 +//                 class SubClass extends SuperClass { }
  2.1880 +//                  */
  2.1881 +
  2.1882 +//                 //@Inherited only works for classes, no switch cases for method, field, package
  2.1883 +//                 if (srcType == SrcType.CLASS) {
  2.1884 +//                     //Contents for SuperClass
  2.1885 +//                     anno = Helper.ContentVars.BASEANNO.getVal();
  2.1886 +//                     replaceVal = commonStmts + "\n" + anno;
  2.1887 +//                     String superClassContents = srcType.getTemplate()
  2.1888 +//                             .replace("#CN", SUPERCLASS)
  2.1889 +//                             .replace("#REPLACE", replaceVal);
  2.1890 +
  2.1891 +//                     //Contents for SubClass that extends SuperClass
  2.1892 +//                     anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
  2.1893 +//                     replaceVal = expectedVals + "\n" + anno;
  2.1894 +//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1895 +//                             .replace("#CN", className)
  2.1896 +//                             .replace("#SN", SUPERCLASS)
  2.1897 +//                             .replace("#REPLACE", replaceVal);
  2.1898 +
  2.1899 +//                     contents = superClassContents + subClassContents;
  2.1900 +//                     srcFileObj = Helper.getFile(className, contents);
  2.1901 +//                     files = Arrays.asList(srcFileObj);
  2.1902 +//                 }
  2.1903 +//                 return files;
  2.1904 +//             }
  2.1905 +//         },
  2.1906 +        SingleOnSuperContainerAndSingleOnSub_Inherited(
  2.1907 +        "@ExpectedBase(value=Foo.class, "
  2.1908 +                + "getAnnotationVal = \"Foo\", "
  2.1909 +                + "getAnnotationsVals = {"
  2.1910 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1911 +                + "getDeclAnnosVals = {"
  2.1912 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
  2.1913 +                + "getDeclAnnoVal = \"Foo\","
  2.1914 +                + "getAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"},"
  2.1915 +                + "getDeclAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"})",
  2.1916 +        "@ExpectedContainer(value=FooContainer.class, "
  2.1917 +                + "getAnnotationVal = \"FooContainer\", "
  2.1918 +                + "getAnnotationsVals = {"
  2.1919 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1920 +                + "getDeclAnnosVals = {"
  2.1921 +                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
  2.1922 +                + "getDeclAnnoVal = \"FooContainer\","
  2.1923 +                + "getAnnosArgs = {\"FooContainer\"},"
  2.1924 +                + "getDeclAnnosArgs = {\"FooContainer\"})") {
  2.1925 +
  2.1926 +            @Override
  2.1927 +            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.1928 +                    String className) {
  2.1929 +                String anno = "";
  2.1930 +                String replaceVal = "";
  2.1931 +                String contents = "";
  2.1932 +                JavaFileObject srcFileObj = null;
  2.1933 +                Iterable<? extends JavaFileObject> files = null;
  2.1934 +                String expectedVals = "\n" + getExpectedBase() + "\n"
  2.1935 +                        + getExpectedContainer() + "\n";
  2.1936 +                StringBuilder commonStmts = getCommonStmts(true);
  2.1937 +
  2.1938 +                /*
  2.1939 +                Sample testSrc:
  2.1940 +                @Retention(RetentionPolicy.RUNTIME)
  2.1941 +                @Inherited
  2.1942 +                @interface Foo {}
  2.1943 +
  2.1944 +                @Retention(RetentionPolicy.RUNTIME)
  2.1945 +                @Inherited
  2.1946 +                @Repeatable(FooContainer.class)
  2.1947 +                @interface FooContainer {
  2.1948 +                Foo[] value();
  2.1949 +                }
  2.1950 +
  2.1951 +                @Foo
  2.1952 +                class SuperClass { }
  2.1953 +
  2.1954 +                @ExpectedBase
  2.1955 +                @ExpectedContainer
  2.1956 +                @FooContainer(value = {@Foo, @Foo}) @Foo
  2.1957 +                class SubClass extends SuperClass {}
  2.1958 +                 */
  2.1959 +
  2.1960 +                if (srcType == SrcType.CLASS) {
  2.1961 +                    //Contents for SuperClass
  2.1962 +                    anno = Helper.ContentVars.BASEANNO.getVal();
  2.1963 +                    replaceVal = commonStmts + "\n" + anno;
  2.1964 +                    String superClassContents = srcType.getTemplate()
  2.1965 +                            .replace("#CN", SUPERCLASS)
  2.1966 +                            .replace("#REPLACE", replaceVal);
  2.1967 +
  2.1968 +                    //Contents for SubClass that extends SuperClass
  2.1969 +                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
  2.1970 +                            + Helper.ContentVars.BASEANNO.getVal();
  2.1971 +                    replaceVal = expectedVals + "\n" + anno;
  2.1972 +                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.1973 +                            .replace("#CN", className)
  2.1974 +                            .replace("#SN", SUPERCLASS)
  2.1975 +                            .replace("#REPLACE", replaceVal);
  2.1976 +
  2.1977 +                    contents = superClassContents + subClassContents;
  2.1978 +                    srcFileObj = Helper.getFile(className, contents);
  2.1979 +                    files = Arrays.asList(srcFileObj);
  2.1980 +                }
  2.1981 +                return files;
  2.1982 +            }
  2.1983 +        },
  2.1984 +//          // TestCase not working as expected, JDK-8004912
  2.1985 +//          ContainerAndSingleOnSuperSingleOnSub_Inherited(
  2.1986 +//          "@ExpectedBase(value=Foo.class, "
  2.1987 +//                  + "getAnnotationVal = \"Foo\", "
  2.1988 +//                  + "getAnnotationsVals = {"
  2.1989 +//                  +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1990 +//                  + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
  2.1991 +//                  + "getDeclAnnoVal = \"Foo\","
  2.1992 +//                  + "getAnnosArgs = {\"Foo\"},"
  2.1993 +//                  + "getDeclAnnosArgs = {\"Foo\"})",
  2.1994 +//          "@ExpectedContainer(value=FooContainer.class, "
  2.1995 +//                  + "getAnnotationVal = \"FooContainer\", "
  2.1996 +//                  + "getAnnotationsVals = {"
  2.1997 +//                  +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
  2.1998 +//                  + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
  2.1999 +//                  + "getDeclAnnoVal = \"NULL\","
  2.2000 +//                  + "getAnnosArgs = {\"FooContainer\"},"
  2.2001 +//                  + "getDeclAnnosArgs = {})") {
  2.2002 +
  2.2003 +//              @Override
  2.2004 +//              public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.2005 +//                      String className) {
  2.2006 +//                  String anno = "";
  2.2007 +//                  String replaceVal = "";
  2.2008 +//                  String contents = "";
  2.2009 +//                  JavaFileObject srcFileObj = null;
  2.2010 +//                  Iterable<? extends JavaFileObject> files = null;
  2.2011 +
  2.2012 +//                  String expectedVals = "\n" + getExpectedBase() + "\n"
  2.2013 +//                          + getExpectedContainer() + "\n";
  2.2014 +//                  StringBuilder commonStmts = getCommonStmts(true);
  2.2015 +
  2.2016 +//                  /*
  2.2017 +//                  Sample testSrc:
  2.2018 +//                  @Retention(RetentionPolicy.RUNTIME)
  2.2019 +//                  @Inherited
  2.2020 +//                  @Repeatable(FooContainer.class)
  2.2021 +//                  @interface Foo {}
  2.2022 +
  2.2023 +//                  @Retention(RetentionPolicy.RUNTIME)
  2.2024 +//                  @Inherited
  2.2025 +//                  @interface FooContainer {
  2.2026 +//                  Foo[] value();
  2.2027 +//                  }
  2.2028 +
  2.2029 +//                  @FooContainer(value = {@Foo, @Foo})
  2.2030 +//                  @Foo
  2.2031 +//                  class SuperClass { }
  2.2032 +
  2.2033 +//                  @ExpectedBase
  2.2034 +//                  @ExpectedContainer
  2.2035 +//                  @Foo
  2.2036 +//                  class SubClass extends SuperClass { }
  2.2037 +//                   */
  2.2038 +
  2.2039 +//                  //@Inherited only works for classes, no switch cases for method, field, package
  2.2040 +//                  if (srcType == SrcType.CLASS) {
  2.2041 +//                      //Contents for SuperClass
  2.2042 +//                      anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
  2.2043 +//                              + Helper.ContentVars.BASEANNO.getVal();
  2.2044 +//                      replaceVal = commonStmts + "\n" + anno;
  2.2045 +//                      String superClassContents = srcType.getTemplate()
  2.2046 +//                              .replace("#CN", SUPERCLASS)
  2.2047 +//                              .replace("#REPLACE", replaceVal);
  2.2048 +
  2.2049 +//                      //Contents for SubClass that extends SuperClass
  2.2050 +//                      anno = Helper.ContentVars.BASEANNO.getVal();
  2.2051 +//                      replaceVal = expectedVals + "\n" + anno;
  2.2052 +//                      String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
  2.2053 +//                              .replace("#CN", className)
  2.2054 +//                              .replace("#SN", SUPERCLASS)
  2.2055 +//                              .replace("#REPLACE", replaceVal);
  2.2056 +
  2.2057 +//                      contents = superClassContents + subClassContents;
  2.2058 +//                      srcFileObj = Helper.getFile(className, contents);
  2.2059 +//                      files = Arrays.asList(srcFileObj);
  2.2060 +//                  }
  2.2061 +//                  return files;
  2.2062 +//              }
  2.2063 +//         }
  2.2064 +            ;
  2.2065 +         private String expectedBase, expectedContainer;
  2.2066 +
  2.2067 +         private TestCase(String expectedBase, String expectedContainer) {
  2.2068 +             this.expectedBase = expectedBase;
  2.2069 +             this.expectedContainer = expectedContainer;
  2.2070 +         }
  2.2071 +
  2.2072 +         public String getExpectedBase() {
  2.2073 +             return expectedBase;
  2.2074 +         }
  2.2075 +
  2.2076 +         public String getExpectedContainer() {
  2.2077 +             return expectedContainer;
  2.2078 +         }
  2.2079 +
  2.2080 +         // Each enum element should override this method
  2.2081 +         public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
  2.2082 +                 String className) {
  2.2083 +             return null;
  2.2084 +         }
  2.2085 +    }
  2.2086 +
  2.2087 +    /*
  2.2088 +     * Each srctype has its template defined used for test src generation
  2.2089 +     * Primary src types: class, method, field, package define
  2.2090 +     *                    getExpectedBase() and getExpectedContainer()
  2.2091 +     */
  2.2092 +    enum SrcType {
  2.2093 +
  2.2094 +        CLASS("\n#REPLACE\nclass #CN { } ") {
  2.2095 +
  2.2096 +            @Override
  2.2097 +            public ExpectedBase getExpectedBase(Class<?> c) {
  2.2098 +                return c.getAnnotation(ExpectedBase.class);
  2.2099 +            }
  2.2100 +
  2.2101 +            @Override
  2.2102 +            public ExpectedContainer getExpectedContainer(Class<?> c) {
  2.2103 +                return c.getAnnotation(ExpectedContainer.class);
  2.2104 +            }
  2.2105 +        },
  2.2106 +        METHOD("class #CN  {\n" + "   " + "#REPLACE\n" + "   void "
  2.2107 +        + TESTMETHOD + "() {} \n" + "}\n") {
  2.2108 +
  2.2109 +            @Override
  2.2110 +            public ExpectedBase getExpectedBase(Class<?> c) {
  2.2111 +                ExpectedBase ret = null;
  2.2112 +                try {
  2.2113 +                    ret = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
  2.2114 +                            ExpectedBase.class);
  2.2115 +                } catch (NoSuchMethodException nme) {
  2.2116 +                    error("Could not get " + TESTMETHOD + " for className "
  2.2117 +                            + c.getName() + " Exception:\n" + nme);
  2.2118 +                }
  2.2119 +                return ret;
  2.2120 +            }
  2.2121 +
  2.2122 +            @Override
  2.2123 +            public ExpectedContainer getExpectedContainer(Class<?> c) {
  2.2124 +                ExpectedContainer ret = null;
  2.2125 +                try {
  2.2126 +                    ret = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
  2.2127 +                            ExpectedContainer.class);
  2.2128 +                } catch (NoSuchMethodException nme) {
  2.2129 +                    error("Could not get " + TESTMETHOD + " for className "
  2.2130 +                            + c.getName() + " Exception:\n" + nme);
  2.2131 +                }
  2.2132 +                return ret;
  2.2133 +
  2.2134 +            }
  2.2135 +        },
  2.2136 +        FIELD("class #CN  {\n" + "   " + "#REPLACE\n" + "   int " + TESTFIELD
  2.2137 +        + " = 0; \n" + "}\n") {
  2.2138 +
  2.2139 +            @Override
  2.2140 +            public ExpectedBase getExpectedBase(Class<?> c) {
  2.2141 +                ExpectedBase ret = null;
  2.2142 +                try {
  2.2143 +                    ret = c.getDeclaredField(TESTFIELD).getAnnotation(
  2.2144 +                            ExpectedBase.class);
  2.2145 +                } catch (NoSuchFieldException nme) {
  2.2146 +                    error("Could not get " + TESTFIELD + " for className "
  2.2147 +                            + c.getName() + " Exception:\n" + nme);
  2.2148 +                }
  2.2149 +                return ret;
  2.2150 +            }
  2.2151 +
  2.2152 +            @Override
  2.2153 +            public ExpectedContainer getExpectedContainer(Class<?> c) {
  2.2154 +                ExpectedContainer ret = null;
  2.2155 +                try {
  2.2156 +                    ret = c.getDeclaredField(TESTFIELD).getAnnotation(
  2.2157 +                            ExpectedContainer.class);
  2.2158 +                } catch (NoSuchFieldException nme) {
  2.2159 +                    error("Could not get " + TESTFIELD + " for className "
  2.2160 +                            + c.getName() + " Exception:\n" + nme);
  2.2161 +                }
  2.2162 +                return ret;
  2.2163 +
  2.2164 +            }
  2.2165 +        },
  2.2166 +        PACKAGE("package " + TESTPKG + "; \n" + "class #CN {}") {
  2.2167 +
  2.2168 +            @Override
  2.2169 +            public ExpectedBase getExpectedBase(Class<?> c) {
  2.2170 +                return c.getPackage().getAnnotation(ExpectedBase.class);
  2.2171 +            }
  2.2172 +
  2.2173 +            @Override
  2.2174 +            public ExpectedContainer getExpectedContainer(Class<?> c) {
  2.2175 +                return c.getPackage().getAnnotation(ExpectedContainer.class);
  2.2176 +            }
  2.2177 +        },
  2.2178 +        PKGINFO("#REPLACE1\npackage " + TESTPKG + "; \n" + "#REPLACE2"),
  2.2179 +        INTERFACE("#REPLACE\ninterface #IN { } "),
  2.2180 +        INTERFACEIMPL("#REPLACE\nclass #CN implements #IN {}"),
  2.2181 +        CLASSEXTENDS("#REPLACE\nclass #CN extends #SN {}");
  2.2182 +        String template;
  2.2183 +
  2.2184 +        private SrcType(String template) {
  2.2185 +            this.template = template;
  2.2186 +        }
  2.2187 +
  2.2188 +        public String getTemplate() {
  2.2189 +            return template;
  2.2190 +        }
  2.2191 +
  2.2192 +        // Elements should override
  2.2193 +        public ExpectedBase getExpectedBase(Class<?> c) {
  2.2194 +            return null;
  2.2195 +        }
  2.2196 +
  2.2197 +        public ExpectedContainer getExpectedContainer(Class<?> c) {
  2.2198 +            return null;
  2.2199 +        }
  2.2200 +
  2.2201 +        /*
  2.2202 +         * Returns only primary src types ;
  2.2203 +         */
  2.2204 +        public static SrcType[] getSrcTypes() {
  2.2205 +            return new SrcType[]{CLASS, PACKAGE, METHOD, FIELD};
  2.2206 +        }
  2.2207 +    }
  2.2208 +
  2.2209 +    /*
  2.2210 +     * Each enum constant is one of the 6 methods from AnnotatedElement interface
  2.2211 +     * that needs to be tested.
  2.2212 +     * Each enum constant overrides these 4 methods:
  2.2213 +     * - getActualAnnoBase(SrcType srcType, Class<?> c)
  2.2214 +     * - getActualAnnoContainer(SrcType srcType, Class<?> c)
  2.2215 +     * - getExpectedAnnoBase(SrcType srcType, Class<?> c)
  2.2216 +     * - getExpectedAnnoContainer(SrcType srcType, Class<?> c)
  2.2217 +     */
  2.2218 +    enum TestMethod {
  2.2219 +
  2.2220 +        GET_ANNO("getAnnotation") {
  2.2221 +
  2.2222 +            @Override
  2.2223 +            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2224 +                Annotation[] actualAnno = new Annotation[1];
  2.2225 +                switch (srcType) {
  2.2226 +                    case CLASS:
  2.2227 +                        actualAnno[0] = c.getAnnotation(srcType.getExpectedBase(c).value());
  2.2228 +                        break;
  2.2229 +                    case PACKAGE:
  2.2230 +                        actualAnno[0] = c.getPackage().getAnnotation(
  2.2231 +                                srcType.getExpectedBase(c).value());
  2.2232 +                        break;
  2.2233 +                    case METHOD:
  2.2234 +                        try {
  2.2235 +                            actualAnno[0] = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
  2.2236 +                                    srcType.getExpectedBase(c).value());
  2.2237 +                        } catch (NoSuchMethodException nme) {
  2.2238 +                            error("Could not get " + TESTMETHOD
  2.2239 +                                    + " for className = " + c.getName()
  2.2240 +                                    + "Exception = " + nme);
  2.2241 +                        }
  2.2242 +                        break;
  2.2243 +                    case FIELD:
  2.2244 +                        try {
  2.2245 +                            actualAnno[0] = c.getDeclaredField(TESTFIELD).getAnnotation(
  2.2246 +                                    srcType.getExpectedBase(c).value());
  2.2247 +                        } catch (NoSuchFieldException nfe) {
  2.2248 +                            error("Could not get " + TESTFIELD
  2.2249 +                                    + " for className = " + c.getName()
  2.2250 +                                    + "Exception = " + nfe);
  2.2251 +                        }
  2.2252 +                        break;
  2.2253 +                }
  2.2254 +                return actualAnno;
  2.2255 +            }
  2.2256 +
  2.2257 +            @Override
  2.2258 +            public Annotation[] getActualAnnoContainer(SrcType srcType,
  2.2259 +                    Class<?> c) {
  2.2260 +                Annotation[] actualAnno = new Annotation[1];
  2.2261 +                switch (srcType) {
  2.2262 +                    case CLASS:
  2.2263 +                        actualAnno[0] = c.getAnnotation(srcType.getExpectedContainer(c).value());
  2.2264 +                        break;
  2.2265 +                    case PACKAGE:
  2.2266 +                        actualAnno[0] = c.getPackage().getAnnotation(
  2.2267 +                                srcType.getExpectedContainer(c).value());
  2.2268 +                        break;
  2.2269 +                    case METHOD:
  2.2270 +                        try {
  2.2271 +                            actualAnno[0] = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
  2.2272 +                                    srcType.getExpectedContainer(c).value());
  2.2273 +                        } catch (NoSuchMethodException nme) {
  2.2274 +                            error("Could not get " + TESTMETHOD
  2.2275 +                                    + " for className = " + c.getName()
  2.2276 +                                    + "Exception = " + nme);
  2.2277 +                        }
  2.2278 +                        break;
  2.2279 +                    case FIELD:
  2.2280 +                        try {
  2.2281 +                            actualAnno[0] = c.getDeclaredField(TESTFIELD).getAnnotation(
  2.2282 +                                    srcType.getExpectedContainer(c).value());
  2.2283 +                        } catch (NoSuchFieldException nfe) {
  2.2284 +                            error("Could not get " + TESTFIELD
  2.2285 +                                    + " for className = " + c.getName()
  2.2286 +                                    + "Exception = " + nfe);
  2.2287 +                        }
  2.2288 +                        break;
  2.2289 +                }
  2.2290 +                return actualAnno;
  2.2291 +            }
  2.2292 +
  2.2293 +            @Override
  2.2294 +            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2295 +                String[] expAnno = {srcType.getExpectedBase(c).getAnnotationVal()};
  2.2296 +                return expAnno;
  2.2297 +            }
  2.2298 +
  2.2299 +            @Override
  2.2300 +            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2301 +                String[] expAnno = {srcType.getExpectedContainer(c).getAnnotationVal()};
  2.2302 +                return expAnno;
  2.2303 +            }
  2.2304 +        },
  2.2305 +        GET_ANNOS("getAnnotations") {
  2.2306 +
  2.2307 +            @Override
  2.2308 +            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2309 +                Annotation[] actualAnnos = null;
  2.2310 +                switch (srcType) {
  2.2311 +                    case CLASS:
  2.2312 +                        actualAnnos = c.getAnnotations();
  2.2313 +                        break;
  2.2314 +                    case PACKAGE:
  2.2315 +                        actualAnnos = c.getPackage().getAnnotations();
  2.2316 +                        break;
  2.2317 +                    case METHOD:
  2.2318 +                        try {
  2.2319 +                            actualAnnos = c.getDeclaredMethod(TESTMETHOD).getAnnotations();
  2.2320 +                        } catch (NoSuchMethodException nme) {
  2.2321 +                            error("Could not get " + TESTMETHOD
  2.2322 +                                    + " for className = " + c.getName()
  2.2323 +                                    + "Exception = " + nme);
  2.2324 +                        }
  2.2325 +                        break;
  2.2326 +                    case FIELD:
  2.2327 +                        try {
  2.2328 +                            actualAnnos = c.getDeclaredField(TESTFIELD).getAnnotations();
  2.2329 +                        } catch (NoSuchFieldException nfe) {
  2.2330 +                            error("Could not get " + TESTFIELD
  2.2331 +                                    + " for className = " + c.getName()
  2.2332 +                                    + "Exception = " + nfe);
  2.2333 +                        }
  2.2334 +                        break;
  2.2335 +                }
  2.2336 +                return actualAnnos;
  2.2337 +            }
  2.2338 +
  2.2339 +            @Override
  2.2340 +            public Annotation[] getActualAnnoContainer(SrcType srcType,
  2.2341 +                    Class<?> c) {
  2.2342 +                Annotation[] actualAnnos = null;
  2.2343 +                switch (srcType) {
  2.2344 +                    case CLASS:
  2.2345 +                        actualAnnos = c.getAnnotations();
  2.2346 +                        break;
  2.2347 +                    case PACKAGE:
  2.2348 +                        actualAnnos = c.getPackage().getAnnotations();
  2.2349 +                        break;
  2.2350 +                    case METHOD:
  2.2351 +                        try {
  2.2352 +                            actualAnnos = c.getDeclaredMethod(TESTMETHOD).getAnnotations();
  2.2353 +                        } catch (NoSuchMethodException nme) {
  2.2354 +                            error("Could not get " + TESTMETHOD
  2.2355 +                                    + " for className = " + c.getName()
  2.2356 +                                    + "Exception = " + nme);
  2.2357 +                        }
  2.2358 +                        break;
  2.2359 +                    case FIELD:
  2.2360 +                        try {
  2.2361 +                            actualAnnos = c.getDeclaredField(TESTFIELD).getAnnotations();
  2.2362 +                        } catch (NoSuchFieldException nfe) {
  2.2363 +                            error("Could not get " + TESTFIELD
  2.2364 +                                    + " for className = " + c.getName()
  2.2365 +                                    + "Exception = " + nfe);
  2.2366 +                        }
  2.2367 +                        break;
  2.2368 +                }
  2.2369 +                return actualAnnos;
  2.2370 +            }
  2.2371 +
  2.2372 +            @Override
  2.2373 +            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2374 +                return srcType.getExpectedBase(c).getAnnotationsVals();
  2.2375 +            }
  2.2376 +
  2.2377 +            @Override
  2.2378 +            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2379 +                return srcType.getExpectedContainer(c).getAnnotationsVals();
  2.2380 +            }
  2.2381 +        },
  2.2382 +        GET_DECL_ANNOS("getDeclaredAnnotations") {
  2.2383 +
  2.2384 +            @Override
  2.2385 +            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2386 +                Annotation[] actualDeclAnnos = null;
  2.2387 +                switch (srcType) {
  2.2388 +                    case CLASS:
  2.2389 +                        actualDeclAnnos = c.getDeclaredAnnotations();
  2.2390 +                        break;
  2.2391 +                    case PACKAGE:
  2.2392 +                        actualDeclAnnos = c.getPackage().getDeclaredAnnotations();
  2.2393 +                        break;
  2.2394 +                    case METHOD:
  2.2395 +                        try {
  2.2396 +                            actualDeclAnnos = c.getDeclaredMethod(TESTMETHOD)
  2.2397 +                                    .getDeclaredAnnotations();
  2.2398 +                        } catch (NoSuchMethodException nme) {
  2.2399 +                            error("Could not get " + TESTMETHOD
  2.2400 +                                    + " for className = " + c.getName()
  2.2401 +                                    + "Exception = " + nme);
  2.2402 +                        }
  2.2403 +                        break;
  2.2404 +                    case FIELD:
  2.2405 +                        try {
  2.2406 +                            actualDeclAnnos = c.getDeclaredField(TESTFIELD)
  2.2407 +                                    .getDeclaredAnnotations();
  2.2408 +                        } catch (NoSuchFieldException nfe) {
  2.2409 +                            error("Could not get " + TESTFIELD
  2.2410 +                                    + " for className = " + c.getName()
  2.2411 +                                    + "Exception = " + nfe);
  2.2412 +                        }
  2.2413 +                        break;
  2.2414 +                }
  2.2415 +                return actualDeclAnnos;
  2.2416 +            }
  2.2417 +
  2.2418 +            @Override
  2.2419 +            public Annotation[] getActualAnnoContainer(SrcType srcType,
  2.2420 +                    Class<?> c) {
  2.2421 +                Annotation[] actualDeclAnnos = null;
  2.2422 +                switch (srcType) {
  2.2423 +                    case CLASS:
  2.2424 +                        actualDeclAnnos = c.getDeclaredAnnotations();
  2.2425 +                        break;
  2.2426 +                    case PACKAGE:
  2.2427 +                        actualDeclAnnos = c.getPackage().getDeclaredAnnotations();
  2.2428 +                        break;
  2.2429 +                    case METHOD:
  2.2430 +                        try {
  2.2431 +                            actualDeclAnnos = c.getDeclaredMethod(TESTMETHOD)
  2.2432 +                                    .getDeclaredAnnotations();
  2.2433 +                        } catch (NoSuchMethodException nme) {
  2.2434 +                            error("Could not get " + TESTMETHOD
  2.2435 +                                    + " for className = " + c.getName()
  2.2436 +                                    + "Exception = " + nme);
  2.2437 +                        }
  2.2438 +                        break;
  2.2439 +                    case FIELD:
  2.2440 +                        try {
  2.2441 +                            actualDeclAnnos = c.getDeclaredField(TESTFIELD)
  2.2442 +                                    .getDeclaredAnnotations();
  2.2443 +                        } catch (NoSuchFieldException nfe) {
  2.2444 +                            error("Could not get " + TESTFIELD
  2.2445 +                                    + " for className = " + c.getName()
  2.2446 +                                    + "Exception = " + nfe);
  2.2447 +                        }
  2.2448 +                        break;
  2.2449 +                }
  2.2450 +                return actualDeclAnnos;
  2.2451 +            }
  2.2452 +
  2.2453 +            @Override
  2.2454 +            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2455 +                return srcType.getExpectedBase(c).getDeclAnnosVals();
  2.2456 +            }
  2.2457 +
  2.2458 +            @Override
  2.2459 +            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2460 +                return srcType.getExpectedContainer(c).getDeclAnnosVals();
  2.2461 +            }
  2.2462 +        },
  2.2463 +        GET_DECL_ANNO("getDeclaredAnnotation") {
  2.2464 +
  2.2465 +            @Override
  2.2466 +            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2467 +                Annotation[] actualDeclAnno = new Annotation[1];
  2.2468 +                switch (srcType) {
  2.2469 +                    case CLASS:
  2.2470 +                        actualDeclAnno[0] = c.getDeclaredAnnotation(
  2.2471 +                                srcType.getExpectedBase(c).value());
  2.2472 +                        break;
  2.2473 +                    case PACKAGE:
  2.2474 +                        actualDeclAnno[0] = c.getPackage().getDeclaredAnnotation(
  2.2475 +                                srcType.getExpectedBase(c).value());
  2.2476 +                        break;
  2.2477 +                    case METHOD:
  2.2478 +                        try {
  2.2479 +                            actualDeclAnno[0] = c.getDeclaredMethod(TESTMETHOD)
  2.2480 +                                    .getDeclaredAnnotation(
  2.2481 +                                        srcType.getExpectedBase(c).value());
  2.2482 +                        } catch (NoSuchMethodException nme) {
  2.2483 +                            error("Could not get " + TESTMETHOD
  2.2484 +                                    + " for className = " + c.getName()
  2.2485 +                                    + "Exception = " + nme);
  2.2486 +                        }
  2.2487 +                        break;
  2.2488 +                    case FIELD:
  2.2489 +                        try {
  2.2490 +                            actualDeclAnno[0] = c.getDeclaredField(TESTFIELD)
  2.2491 +                                    .getDeclaredAnnotation(
  2.2492 +                                        srcType.getExpectedBase(c).value());
  2.2493 +                        } catch (NoSuchFieldException nfe) {
  2.2494 +                            error("Could not get " + TESTFIELD
  2.2495 +                                    + " for className = " + c.getName()
  2.2496 +                                    + "Exception = " + nfe);
  2.2497 +                        }
  2.2498 +                        break;
  2.2499 +                }
  2.2500 +                return actualDeclAnno;
  2.2501 +            }
  2.2502 +
  2.2503 +            @Override
  2.2504 +            public Annotation[] getActualAnnoContainer(SrcType srcType,
  2.2505 +                    Class<?> c) {
  2.2506 +                Annotation[] actualDeclAnno = new Annotation[1];
  2.2507 +                switch (srcType) {
  2.2508 +                    case CLASS:
  2.2509 +                        actualDeclAnno[0] = c.getDeclaredAnnotation(
  2.2510 +                                srcType.getExpectedContainer(c).value());
  2.2511 +                        break;
  2.2512 +                    case PACKAGE:
  2.2513 +                        actualDeclAnno[0] = c.getPackage().getDeclaredAnnotation(
  2.2514 +                                srcType.getExpectedContainer(c).value());
  2.2515 +                        break;
  2.2516 +                    case METHOD:
  2.2517 +                        try {
  2.2518 +                            actualDeclAnno[0] = c.getDeclaredMethod(TESTMETHOD)
  2.2519 +                                    .getDeclaredAnnotation(
  2.2520 +                                        srcType.getExpectedContainer(c).value());
  2.2521 +                        } catch (NoSuchMethodException nme) {
  2.2522 +                            error("Could not get " + TESTMETHOD
  2.2523 +                                    + " for className = " + c.getName()
  2.2524 +                                    + "Exception = " + nme);
  2.2525 +                        }
  2.2526 +                        break;
  2.2527 +                    case FIELD:
  2.2528 +                        try {
  2.2529 +                            actualDeclAnno[0] = c.getDeclaredField(TESTFIELD)
  2.2530 +                                    .getDeclaredAnnotation(
  2.2531 +                                        srcType.getExpectedContainer(c).value());
  2.2532 +                        } catch (NoSuchFieldException nfe) {
  2.2533 +                            error("Could not get " + TESTFIELD
  2.2534 +                                    + " for className = " + c.getName()
  2.2535 +                                    + "Exception = " + nfe);
  2.2536 +                        }
  2.2537 +                        break;
  2.2538 +                }
  2.2539 +                return actualDeclAnno;
  2.2540 +            }
  2.2541 +
  2.2542 +            @Override
  2.2543 +            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2544 +                String[] expAnno = {srcType.getExpectedBase(c).getDeclAnnoVal()};
  2.2545 +                return expAnno;
  2.2546 +            }
  2.2547 +
  2.2548 +            @Override
  2.2549 +            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2550 +                String[] expAnno = {srcType.getExpectedContainer(c).getDeclAnnoVal()};
  2.2551 +                return expAnno;
  2.2552 +            }
  2.2553 +        }, // new
  2.2554 +        GET_ANNOS_ARG("getAnnotationsArg") {
  2.2555 +
  2.2556 +            @Override
  2.2557 +            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2558 +                Annotation[] actualAnnoArgs = null;
  2.2559 +                switch (srcType) {
  2.2560 +                    case CLASS:
  2.2561 +                        actualAnnoArgs = c.getAnnotationsByType(srcType.getExpectedBase(c).value());
  2.2562 +                        break;
  2.2563 +                    case PACKAGE:
  2.2564 +                        actualAnnoArgs = c.getPackage().getAnnotationsByType(
  2.2565 +                                srcType.getExpectedBase(c).value());
  2.2566 +                        break;
  2.2567 +                    case METHOD:
  2.2568 +                        try {
  2.2569 +                            actualAnnoArgs = c.getDeclaredMethod(TESTMETHOD)
  2.2570 +                                    .getAnnotationsByType(
  2.2571 +                                        srcType.getExpectedBase(c).value());
  2.2572 +                        } catch (NoSuchMethodException nme) {
  2.2573 +                            error("Could not get " + TESTMETHOD
  2.2574 +                                    + " for className = " + c.getName()
  2.2575 +                                    + "Exception = " + nme);
  2.2576 +                        }
  2.2577 +                        break;
  2.2578 +                    case FIELD:
  2.2579 +                        try {
  2.2580 +                            actualAnnoArgs = c.getDeclaredField(TESTFIELD)
  2.2581 +                                    .getAnnotationsByType(
  2.2582 +                                        srcType.getExpectedBase(c).value());
  2.2583 +                        } catch (NoSuchFieldException nfe) {
  2.2584 +                            error("Could not get " + TESTFIELD
  2.2585 +                                    + " for className = " + c.getName()
  2.2586 +                                    + "Exception = " + nfe);
  2.2587 +                        }
  2.2588 +                        break;
  2.2589 +                }
  2.2590 +                return actualAnnoArgs;
  2.2591 +            }
  2.2592 +
  2.2593 +            @Override
  2.2594 +            public Annotation[] getActualAnnoContainer(SrcType srcType,
  2.2595 +                    Class<?> c) {
  2.2596 +                Annotation[] actualAnnoArgs = null;
  2.2597 +                switch (srcType) {
  2.2598 +                    case CLASS:
  2.2599 +                        actualAnnoArgs = c.getAnnotationsByType(srcType.getExpectedContainer(c).value());
  2.2600 +                        break;
  2.2601 +                    case PACKAGE:
  2.2602 +                        actualAnnoArgs = c.getPackage().getAnnotationsByType(
  2.2603 +                                srcType.getExpectedContainer(c).value());
  2.2604 +                        break;
  2.2605 +                    case METHOD:
  2.2606 +                        try {
  2.2607 +                            actualAnnoArgs = c.getDeclaredMethod(TESTMETHOD)
  2.2608 +                                    .getAnnotationsByType(
  2.2609 +                                        srcType.getExpectedContainer(c).value());
  2.2610 +                        } catch (NoSuchMethodException nme) {
  2.2611 +                            error("Could not get " + TESTMETHOD
  2.2612 +                                    + " for className = " + c.getName()
  2.2613 +                                    + "Exception = " + nme);
  2.2614 +                        }
  2.2615 +                        break;
  2.2616 +                    case FIELD:
  2.2617 +                        try {
  2.2618 +                            actualAnnoArgs = c.getDeclaredField(TESTFIELD)
  2.2619 +                                    .getAnnotationsByType(
  2.2620 +                                        srcType.getExpectedContainer(c).value());
  2.2621 +                        } catch (NoSuchFieldException nfe) {
  2.2622 +                            error("Could not get " + TESTFIELD
  2.2623 +                                    + " for className = " + c.getName()
  2.2624 +                                    + "Exception = " + nfe);
  2.2625 +                        }
  2.2626 +                        break;
  2.2627 +                }
  2.2628 +                return actualAnnoArgs;
  2.2629 +            }
  2.2630 +
  2.2631 +            @Override
  2.2632 +            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2633 +                return srcType.getExpectedBase(c).getAnnosArgs();
  2.2634 +            }
  2.2635 +
  2.2636 +            @Override
  2.2637 +            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2638 +                return srcType.getExpectedContainer(c).getAnnosArgs();
  2.2639 +            }
  2.2640 +        }, // new
  2.2641 +        GET_DECL_ANNOS_ARG("getDeclAnnosArg") {
  2.2642 +
  2.2643 +            @Override
  2.2644 +            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2645 +                Annotation[] actualDeclAnnosArgs = null;
  2.2646 +                switch (srcType) {
  2.2647 +                    case CLASS:
  2.2648 +                        actualDeclAnnosArgs = c.getDeclaredAnnotationsByType(
  2.2649 +                                srcType.getExpectedBase(c).value());
  2.2650 +                        break;
  2.2651 +                    case PACKAGE:
  2.2652 +                        actualDeclAnnosArgs = c.getPackage().getDeclaredAnnotationsByType(
  2.2653 +                                srcType.getExpectedBase(c).value());
  2.2654 +                        break;
  2.2655 +                    case METHOD:
  2.2656 +                        try {
  2.2657 +                            actualDeclAnnosArgs = c.getDeclaredMethod(TESTMETHOD)
  2.2658 +                                    .getDeclaredAnnotationsByType(
  2.2659 +                                        srcType.getExpectedBase(c).value());
  2.2660 +                        } catch (NoSuchMethodException nme) {
  2.2661 +                            error("Could not get " + TESTMETHOD
  2.2662 +                                    + " for className = " + c.getName()
  2.2663 +                                    + "Exception = " + nme);
  2.2664 +                        }
  2.2665 +                        break;
  2.2666 +                    case FIELD:
  2.2667 +                        try {
  2.2668 +                            actualDeclAnnosArgs = c.getDeclaredField(TESTFIELD)
  2.2669 +                                    .getDeclaredAnnotationsByType(
  2.2670 +                                        srcType.getExpectedBase(c).value());
  2.2671 +                        } catch (NoSuchFieldException nfe) {
  2.2672 +                            error("Could not get " + TESTFIELD
  2.2673 +                                    + " for className = " + c.getName()
  2.2674 +                                    + "Exception = " + nfe);
  2.2675 +                        }
  2.2676 +                        break;
  2.2677 +                }
  2.2678 +                return actualDeclAnnosArgs;
  2.2679 +            }
  2.2680 +
  2.2681 +            @Override
  2.2682 +            public Annotation[] getActualAnnoContainer(SrcType srcType,
  2.2683 +                    Class<?> c) {
  2.2684 +                Annotation[] actualDeclAnnosArgs = null;
  2.2685 +                switch (srcType) {
  2.2686 +                    case CLASS:
  2.2687 +                        actualDeclAnnosArgs = c.getDeclaredAnnotationsByType(
  2.2688 +                                srcType.getExpectedContainer(c).value());
  2.2689 +                        break;
  2.2690 +                    case PACKAGE:
  2.2691 +                        actualDeclAnnosArgs = c.getPackage().getDeclaredAnnotationsByType(
  2.2692 +                                srcType.getExpectedContainer(c).value());
  2.2693 +                        break;
  2.2694 +                    case METHOD:
  2.2695 +                        try {
  2.2696 +                            actualDeclAnnosArgs = c.getDeclaredMethod(TESTMETHOD)
  2.2697 +                                    .getDeclaredAnnotationsByType(
  2.2698 +                                        srcType.getExpectedContainer(c).value());
  2.2699 +                        } catch (NoSuchMethodException nme) {
  2.2700 +                            error("Could not get " + TESTMETHOD
  2.2701 +                                    + " for className = " + c.getName()
  2.2702 +                                    + "Exception = " + nme);
  2.2703 +                        }
  2.2704 +                        break;
  2.2705 +                    case FIELD:
  2.2706 +                        try {
  2.2707 +                            actualDeclAnnosArgs = c.getDeclaredField(TESTFIELD)
  2.2708 +                                   .getDeclaredAnnotationsByType(
  2.2709 +                                        srcType.getExpectedContainer(c).value());
  2.2710 +                        } catch (NoSuchFieldException nfe) {
  2.2711 +                            error("Could not get " + TESTFIELD
  2.2712 +                                    + " for className = " + c.getName()
  2.2713 +                                    + "Exception = " + nfe);
  2.2714 +                        }
  2.2715 +                        break;
  2.2716 +                }
  2.2717 +                return actualDeclAnnosArgs;
  2.2718 +            }
  2.2719 +
  2.2720 +            @Override
  2.2721 +            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2722 +                return srcType.getExpectedBase(c).getDeclAnnosArgs();
  2.2723 +            }
  2.2724 +
  2.2725 +            @Override
  2.2726 +            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2727 +                return srcType.getExpectedContainer(c).getDeclAnnosArgs();
  2.2728 +            }
  2.2729 +        }; // new
  2.2730 +        String name;
  2.2731 +
  2.2732 +        private TestMethod(String name) {
  2.2733 +            this.name = name;
  2.2734 +        }
  2.2735 +
  2.2736 +        public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
  2.2737 +            return null;
  2.2738 +        }
  2.2739 +
  2.2740 +        public Annotation[] getActualAnnoContainer(SrcType srcType, Class<?> c) {
  2.2741 +            return null;
  2.2742 +        }
  2.2743 +
  2.2744 +        public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
  2.2745 +            return null;
  2.2746 +        }
  2.2747 +
  2.2748 +        public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
  2.2749 +            return null;
  2.2750 +        }
  2.2751 +    }
  2.2752 +
  2.2753 +    /*
  2.2754 +     * For a given srcType and class object, compare expectedBase and actualBase
  2.2755 +     * annotations as well as expectedContainer and actualContainer annotations.
  2.2756 +     *
  2.2757 +     * Return true if both comparisons are true else return false.
  2.2758 +     *
  2.2759 +     */
  2.2760 +    protected static void checkAnnoValues(SrcType srcType, Class<?> c) {
  2.2761 +
  2.2762 +        // Load @ExpectedBase and @ExpectedContainer
  2.2763 +        ExpectedBase eb = srcType.getExpectedBase(c);
  2.2764 +        ExpectedContainer ec = srcType.getExpectedContainer(c);
  2.2765 +        if (eb == null) {
  2.2766 +            error("Did not find ExpectedBase Annotation, Test will exit");
  2.2767 +            throw new RuntimeException();
  2.2768 +        }
  2.2769 +        if (ec == null) {
  2.2770 +            error("Did not find ExpectedContainer Annotation, Test will exit");
  2.2771 +            throw new RuntimeException();
  2.2772 +        }
  2.2773 +
  2.2774 +        for (TestMethod testMethod : TestMethod.values()) {
  2.2775 +            debugPrint("---------------------------------------------");
  2.2776 +            debugPrint("Test method = " + testMethod);
  2.2777 +            boolean isBasePass = true;
  2.2778 +            boolean isConPass = true;
  2.2779 +            // ExpectedBase = Annotation, no annotation is defined, skip comparison
  2.2780 +            if (!eb.value().getSimpleName().equalsIgnoreCase("Annotation")) {
  2.2781 +                isBasePass = compareAnnotations(
  2.2782 +                        testMethod.getActualAnnoBase(srcType, c),
  2.2783 +                        testMethod.getExpectedAnnoBase(srcType, c));
  2.2784 +            }
  2.2785 +
  2.2786 +            // ExpectedContainer = Annotation, no annotation is defined, skip comparison
  2.2787 +            if (!ec.value().getSimpleName().equalsIgnoreCase("Annotation")) {
  2.2788 +                isConPass = compareAnnotations(
  2.2789 +                        testMethod.getActualAnnoContainer(srcType, c),
  2.2790 +                        testMethod.getExpectedAnnoContainer(srcType, c));
  2.2791 +            }
  2.2792 +            if (isBasePass && isConPass) {
  2.2793 +                debugPrint("Testcase passed for " + testMethod +
  2.2794 +                        " for className = " + c.getName());
  2.2795 +            } else {
  2.2796 +                debugPrint("Testcase failed for " + testMethod +
  2.2797 +                        " for className = " + c.getName());
  2.2798 +            }
  2.2799 +        }
  2.2800 +    }
  2.2801 +
  2.2802 +    // Annotation comparison: Length should be same and all expected values
  2.2803 +    // should be present in actualAnno[].
  2.2804 +    private static boolean compareAnnotations(Annotation[] actualAnnos,
  2.2805 +            String[] expectedAnnos) {
  2.2806 +        // Length is different
  2.2807 +        if (actualAnnos.length != expectedAnnos.length) {
  2.2808 +            error("Length not same, Actual length = " + actualAnnos.length
  2.2809 +                    + " Expected length = " + expectedAnnos.length);
  2.2810 +            printArrContents(actualAnnos);
  2.2811 +            printArrContents(expectedAnnos);
  2.2812 +            return false;
  2.2813 +        } else {
  2.2814 +            int i = 0;
  2.2815 +            // Length is same and 0
  2.2816 +            if (actualAnnos.length == 0) {
  2.2817 +                // Expected/actual lengths already checked for
  2.2818 +                // equality; no more checks do to
  2.2819 +                return true;
  2.2820 +            }
  2.2821 +            // Expected annotation should be NULL
  2.2822 +            if (actualAnnos[0] == null) {
  2.2823 +                if (expectedAnnos[0].equals("NULL")) {
  2.2824 +                    debugPrint("Arr values are NULL as expected");
  2.2825 +                    return true;
  2.2826 +                } else {
  2.2827 +                    error("Array values are not NULL");
  2.2828 +                    printArrContents(actualAnnos);
  2.2829 +                    printArrContents(expectedAnnos);
  2.2830 +                    return false;
  2.2831 +                }
  2.2832 +            }
  2.2833 +            // Lengths are same, compare array contents
  2.2834 +            String[] actualArr = new String[actualAnnos.length];
  2.2835 +            for (Annotation a : actualAnnos) {
  2.2836 +                actualArr[i++] = a.annotationType().getSimpleName();
  2.2837 +            }
  2.2838 +
  2.2839 +            List<String> actualList = Arrays.asList(actualArr);
  2.2840 +            List<String> expectedList = Arrays.asList(expectedAnnos);
  2.2841 +
  2.2842 +            if (!actualList.containsAll(expectedList)) {
  2.2843 +                error("Array values are not same");
  2.2844 +                printArrContents(actualAnnos);
  2.2845 +                printArrContents(expectedAnnos);
  2.2846 +                return false;
  2.2847 +            } else {
  2.2848 +                debugPrint("Arr values are same as expected");
  2.2849 +            }
  2.2850 +        }
  2.2851 +        return true;
  2.2852 +    }
  2.2853 +
  2.2854 +    private static void printArrContents(Annotation[] actualAnnos) {
  2.2855 +        System.out.print("Actual Arr Values: ");
  2.2856 +        for (Annotation a : actualAnnos) {
  2.2857 +            if (a != null && a.annotationType() != null) {
  2.2858 +                System.out.print("[" + a.annotationType().getSimpleName() + "]");
  2.2859 +            } else {
  2.2860 +                System.out.println("[null]");
  2.2861 +            }
  2.2862 +        }
  2.2863 +        System.out.println();
  2.2864 +    }
  2.2865 +
  2.2866 +    private static void printArrContents(String[] expectedAnnos) {
  2.2867 +        System.out.print("Expected Arr Values: ");
  2.2868 +        for (String s : expectedAnnos) {
  2.2869 +            System.out.print("[" + s + "]");
  2.2870 +        }
  2.2871 +        System.out.println();
  2.2872 +    }
  2.2873 +
  2.2874 +    private ClassLoader getLoader() {
  2.2875 +        return getClass().getClassLoader();
  2.2876 +    }
  2.2877 +
  2.2878 +    private static Class<?> loadClass(String className, ClassLoader parentClassLoader, File... destDirs) {
  2.2879 +        try {
  2.2880 +            List<URL> list = new ArrayList<>();
  2.2881 +            for (File f : destDirs) {
  2.2882 +                list.add(new URL("file:" + f.toString().replace("\\", "/") + "/"));
  2.2883 +            }
  2.2884 +            return Class.forName(className, true, new URLClassLoader(
  2.2885 +                    list.toArray(new URL[list.size()]), parentClassLoader));
  2.2886 +        } catch (ClassNotFoundException | MalformedURLException e) {
  2.2887 +            throw new RuntimeException("Error loading class " + className, e);
  2.2888 +        }
  2.2889 +    }
  2.2890 +
  2.2891 +    private static void printTestSrc(Iterable<? extends JavaFileObject> files) {
  2.2892 +        for (JavaFileObject f : files) {
  2.2893 +            System.out.println("Test file " + f.getName() + ":");
  2.2894 +            try {
  2.2895 +                System.out.println("" + f.getCharContent(true));
  2.2896 +            } catch (IOException e) {
  2.2897 +                throw new RuntimeException(
  2.2898 +                        "Exception when printing test src contents for class " +
  2.2899 +                                f.getName(), e);
  2.2900 +            }
  2.2901 +        }
  2.2902 +
  2.2903 +    }
  2.2904 +
  2.2905 +    public static StringBuilder getCommonStmts(boolean isRepeatable) {
  2.2906 +        StringBuilder sb = new StringBuilder();
  2.2907 +
  2.2908 +        sb.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
  2.2909 +          .append(Helper.ContentVars.IMPORTSTMTS.getVal())
  2.2910 +          .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.2911 +          .append(Helper.ContentVars.INHERITED.getVal());
  2.2912 +        if(isRepeatable) {
  2.2913 +            sb.append(Helper.ContentVars.REPEATABLE.getVal());
  2.2914 +        }
  2.2915 +        sb.append(Helper.ContentVars.BASE.getVal())
  2.2916 +          .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
  2.2917 +          .append(Helper.ContentVars.INHERITED.getVal())
  2.2918 +          .append(Helper.ContentVars.CONTAINER.getVal());
  2.2919 +        return sb;
  2.2920 +    }
  2.2921 +
  2.2922 +    private static int getNumErrors() {
  2.2923 +        return errors;
  2.2924 +    }
  2.2925 +
  2.2926 +    private static void error(String msg) {
  2.2927 +        System.out.println("error: " + msg);
  2.2928 +        errors++;
  2.2929 +    }
  2.2930 +
  2.2931 +    private static void debugPrint(String string) {
  2.2932 +        if(DEBUG)
  2.2933 +            System.out.println(string);
  2.2934 +    }
  2.2935 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedBase.java	Wed Feb 13 23:05:17 2013 -0800
     3.3 @@ -0,0 +1,39 @@
     3.4 +/*
     3.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +package expectedFiles;
    3.28 +import java.lang.annotation.Annotation;
    3.29 +import java.lang.annotation.Retention;
    3.30 +import java.lang.annotation.RetentionPolicy;
    3.31 +@Retention(RetentionPolicy.RUNTIME)
    3.32 +public @interface ExpectedBase {
    3.33 +    Class<? extends Annotation> value() default Annotation.class;
    3.34 +    String getAnnotationVal() default "";
    3.35 +    String[] getAnnotationsVals() default {};
    3.36 +    String[] getDeclAnnosVals() default {};
    3.37 +    // JDK8 methods
    3.38 +    String getDeclAnnoVal() default "";
    3.39 +    String[] getAnnosArgs() default{};
    3.40 +    String[] getDeclAnnosArgs() default {};
    3.41 +}
    3.42 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedContainer.java	Wed Feb 13 23:05:17 2013 -0800
     4.3 @@ -0,0 +1,39 @@
     4.4 +/*
     4.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 +package expectedFiles;
    4.28 +import java.lang.annotation.Annotation;
    4.29 +import java.lang.annotation.Retention;
    4.30 +import java.lang.annotation.RetentionPolicy;
    4.31 +@Retention(RetentionPolicy.RUNTIME)
    4.32 +public @interface ExpectedContainer {
    4.33 +    Class<? extends Annotation> value() default Annotation.class;
    4.34 +    String getAnnotationVal() default "";
    4.35 +    String[] getAnnotationsVals() default {};
    4.36 +    String[] getDeclAnnosVals() default {};
    4.37 +    // JDK8 methods
    4.38 +    String getDeclAnnoVal() default "";
    4.39 +    String[] getAnnosArgs() default{};
    4.40 +    String[] getDeclAnnosArgs() default {};
    4.41 +}
    4.42 +

mercurial