langtools/test/tools/javac/tree/NoPrivateTypesExported.java
author darcy
Thu, 17 Jul 2014 09:47:25 -0700
changeset 25690 b1dac768ab79
parent 21022 08da1099cba7
child 30730 d3ce7619db2c
permissions -rw-r--r--
8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9 Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     1
/*
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 21022
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     4
 *
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     8
 *
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    14
 *
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    18
 *
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    21
 * questions.
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    22
 */
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    23
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    24
/*
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    25
 * @test
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    26
 * @bug 8026180
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    27
 * @summary Ensuring javax.lang.model.**, javax.tools.**, javax.annotation.processing.**
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    28
 *          and com.sun.source.** don't export inappropriate types.
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    29
 * @library /tools/javac/lib
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    30
 * @build JavacTestingAbstractProcessor NoPrivateTypesExported
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    31
 * @compile -processor NoPrivateTypesExported NoPrivateTypesExported.java
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    32
 */
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    33
import java.lang.annotation.Documented;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    34
import java.util.Arrays;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    35
import java.util.HashSet;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    36
import java.util.List;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    37
import java.util.Set;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    38
import javax.annotation.processing.RoundEnvironment;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    39
import javax.lang.model.element.AnnotationMirror;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    40
import javax.lang.model.element.AnnotationValue;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    41
import javax.lang.model.element.Element;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    42
import javax.lang.model.element.ElementKind;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    43
import javax.lang.model.element.ExecutableElement;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    44
import javax.lang.model.element.PackageElement;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    45
import javax.lang.model.element.TypeElement;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    46
import javax.lang.model.element.TypeParameterElement;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    47
import javax.lang.model.element.VariableElement;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    48
import javax.lang.model.type.ArrayType;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    49
import javax.lang.model.type.DeclaredType;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    50
import javax.lang.model.type.IntersectionType;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    51
import javax.lang.model.type.TypeMirror;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    52
import javax.lang.model.type.TypeVariable;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    53
import javax.lang.model.type.WildcardType;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    54
import javax.tools.Diagnostic.Kind;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    55
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    56
public class NoPrivateTypesExported extends JavacTestingAbstractProcessor {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    57
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    58
    private static final String[] javaxLangModelPackages = new String[] {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    59
        "javax.lang.model",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    60
        "javax.lang.model.element",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    61
        "javax.lang.model.type",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    62
        "javax.lang.model.util",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    63
    };
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    64
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    65
    private static final Set<String> javaxLangModelAcceptable;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    66
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    67
    private static final String[] javaxToolsProcessingPackages = new String[] {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    68
        "javax.annotation.processing",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    69
        "javax.tools",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    70
    };
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    71
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    72
    private static final Set<String> javaxToolsProcessingAcceptable;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    73
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    74
    private static final String[] comSunSourcePackages = new String[] {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    75
        "com.sun.source.doctree",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    76
        "com.sun.source.tree",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    77
        "com.sun.source.util"
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    78
    };
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    79
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    80
    private static final Set<String> comSunSourceAcceptable;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    81
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    82
    static {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    83
        javaxLangModelAcceptable = new HashSet<>(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    84
            "java.io.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    85
            "java.lang.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    86
            "java.net.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    87
            "java.nio.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    88
            "java.util.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    89
            "javax.lang.model.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    90
            "javax.annotation.processing.SupportedSourceVersion",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    91
            "jdk.Exported"
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    92
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    93
        Set<String> javaxToolsProcessingAcceptableTemp = new HashSet<>();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    94
        javaxToolsProcessingAcceptableTemp.addAll(javaxLangModelAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    95
        javaxToolsProcessingAcceptableTemp.addAll(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    96
                "javax.annotation.processing.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    97
                "javax.tools."
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    98
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    99
        javaxToolsProcessingAcceptable = javaxToolsProcessingAcceptableTemp;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   100
        Set<String> comSunSourceAcceptableTemp = new HashSet<>();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   101
        comSunSourceAcceptableTemp.addAll(javaxToolsProcessingAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   102
        comSunSourceAcceptableTemp.addAll(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   103
                "com.sun.source.doctree.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   104
                "com.sun.source.tree.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   105
                "com.sun.source.util."
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   106
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   107
        comSunSourceAcceptable = comSunSourceAcceptableTemp;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   108
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   109
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   110
    @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   111
    public boolean process(Set<? extends TypeElement> annotations,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   112
                           RoundEnvironment roundEnv) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   113
        if (roundEnv.processingOver()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   114
            verifyPackage(javaxLangModelPackages, javaxLangModelAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   115
            verifyPackage(javaxToolsProcessingPackages, javaxToolsProcessingAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   116
            verifyPackage(comSunSourcePackages, comSunSourceAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   117
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   118
        return true;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   119
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   120
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   121
    private void verifyPackage(String[] packagesToTest, Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   122
        for (String packageToTest : packagesToTest) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   123
            PackageElement packageElement = processingEnv.getElementUtils()
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   124
                    .getPackageElement(packageToTest);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   125
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   126
            verifyReferredTypesAcceptable(packageElement, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   127
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   128
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   129
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   130
    private void verifyReferredTypesAcceptable(Element rootElement,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   131
                                               final Set<String> acceptable) {
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 21022
diff changeset
   132
        new ElementScanner<Void, Void>() {
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   133
            @Override public Void visitType(TypeElement e, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   134
                verifyTypeAcceptable(e.getSuperclass(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   135
                verifyTypesAcceptable(e.getInterfaces(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   136
                scan(e.getTypeParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   137
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   138
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   139
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   140
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   141
            @Override public Void visitTypeParameter(TypeParameterElement e, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   142
                verifyTypesAcceptable(e.getBounds(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   143
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   144
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   145
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   146
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   147
            @Override public Void visitPackage(PackageElement e, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   148
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   149
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   150
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   151
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   152
            @Override public Void visitVariable(VariableElement e, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   153
                verifyTypeAcceptable(e.asType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   154
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   155
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   156
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   157
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   158
            @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   159
            public Void visitExecutable(ExecutableElement e, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   160
                scan(e.getTypeParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   161
                verifyTypeAcceptable(e.getReturnType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   162
                scan(e.getParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   163
                verifyTypesAcceptable(e.getThrownTypes(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   164
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   165
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   166
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   167
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   168
        }.scan(rootElement, null);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   169
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   170
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   171
    private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   172
                                   Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   173
        for (AnnotationMirror mirror : annotations) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   174
            Element annotationElement = mirror.getAnnotationType().asElement();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   175
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   176
            if (annotationElement.getAnnotation(Documented.class) == null) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   177
                note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   178
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   179
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   180
            verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   181
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   182
            for (AnnotationValue value : mirror.getElementValues().values()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   183
                verifyAnnotationValue(value, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   184
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   185
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   186
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   187
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   188
    private void verifyAnnotationValue(AnnotationValue value,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   189
                                       final Set<String> acceptable) {
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 21022
diff changeset
   190
        value.accept(new SimpleAnnotationValueVisitor<Void, Void>() {
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   191
            @Override public Void visitType(TypeMirror t, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   192
                verifyTypeAcceptable(t, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   193
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   194
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   195
            @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   196
            public Void visitEnumConstant(VariableElement c, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   197
                verifyReferredTypesAcceptable(c, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   198
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   199
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   200
            @Override public Void visitArray(List<? extends AnnotationValue> vals,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   201
                                             Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   202
                for (AnnotationValue val : vals) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   203
                    val.accept(this, p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   204
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   205
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   206
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   207
            @Override protected Void defaultAction(Object o, Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   208
                error("Unexpected AnnotationValue: " + o.toString());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   209
                return super.defaultAction(o, p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   210
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   211
        }, null);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   212
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   213
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   214
    private void verifyTypesAcceptable(Iterable<? extends TypeMirror> types,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   215
                                       Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   216
        if (types == null) return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   217
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   218
        for (TypeMirror type : types) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   219
            verifyTypeAcceptable(type, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   220
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   221
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   222
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   223
    private void verifyTypeAcceptable(TypeMirror type, Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   224
        if (type == null) return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   225
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   226
        verifyAnnotations(type.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   227
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   228
        switch (type.getKind()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   229
            case BOOLEAN: case BYTE: case CHAR: case DOUBLE: case FLOAT:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   230
            case INT: case LONG: case SHORT: case VOID: case NONE: case NULL:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   231
                return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   232
            case DECLARED:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   233
                DeclaredType dt = (DeclaredType) type;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   234
                TypeElement outermostTypeElement = outermostTypeElement(dt.asElement());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   235
                String outermostType = outermostTypeElement.getQualifiedName().toString();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   236
                boolean isAcceptable = false;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   237
                for (String acceptablePackage : acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   238
                    if (outermostType.startsWith(acceptablePackage)) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   239
                        isAcceptable = true;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   240
                        break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   241
                    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   242
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   243
                if (!isAcceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   244
                    error("Type not acceptable for this API: " + dt.toString());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   245
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   246
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   247
                for (TypeMirror bound : dt.getTypeArguments()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   248
                    verifyTypeAcceptable(bound, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   249
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   250
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   251
            case ARRAY:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   252
                verifyTypeAcceptable(((ArrayType) type).getComponentType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   253
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   254
            case INTERSECTION:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   255
                for (TypeMirror element : ((IntersectionType) type).getBounds()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   256
                    verifyTypeAcceptable(element, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   257
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   258
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   259
            case TYPEVAR:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   260
                verifyTypeAcceptable(((TypeVariable) type).getLowerBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   261
                verifyTypeAcceptable(((TypeVariable) type).getUpperBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   262
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   263
            case WILDCARD:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   264
                verifyTypeAcceptable(((WildcardType) type).getExtendsBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   265
                verifyTypeAcceptable(((WildcardType) type).getSuperBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   266
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   267
            default:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   268
                error("Type not acceptable for this API: " + type.toString());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   269
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   270
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   271
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   272
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   273
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   274
    private TypeElement outermostTypeElement(Element el) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   275
        while (el.getEnclosingElement().getKind() != ElementKind.PACKAGE) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   276
            el = el.getEnclosingElement();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   277
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   278
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   279
        return (TypeElement) el;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   280
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   281
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   282
    private void error(String text) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   283
        processingEnv.getMessager().printMessage(Kind.ERROR, text);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   284
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   285
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   286
    private void note(String text) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   287
        processingEnv.getMessager().printMessage(Kind.NOTE, text);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   288
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   289
}