langtools/test/tools/javac/tree/NoPrivateTypesExported.java
author ksrini
Wed, 28 Oct 2015 10:41:30 -0700
changeset 33424 e6bd5406e2cf
parent 30730 d3ce7619db2c
child 34916 16043fc1d90b
permissions -rw-r--r--
8132096: Augment the Compiler Tree API to support the new Simplified Doclet API Reviewed-by: jjg, jlahoda
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
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 25690
diff changeset
     2
 * Copyright (c) 2013, 2015, 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
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 30730
diff changeset
    26
 * @bug 8026180 8132096
21022
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
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 25690
diff changeset
    30
 * @modules java.compiler
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 25690
diff changeset
    31
 *          jdk.compiler
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    32
 * @build JavacTestingAbstractProcessor NoPrivateTypesExported
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    33
 * @compile -processor NoPrivateTypesExported NoPrivateTypesExported.java
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    34
 */
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    35
import java.lang.annotation.Documented;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    36
import java.util.Arrays;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    37
import java.util.HashSet;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    38
import java.util.List;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    39
import java.util.Set;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    40
import javax.annotation.processing.RoundEnvironment;
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.AnnotationMirror;
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.AnnotationValue;
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.Element;
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.ElementKind;
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.ExecutableElement;
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.PackageElement;
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.TypeElement;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    48
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
    49
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
    50
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
    51
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
    52
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
    53
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
    54
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
    55
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
    56
import javax.tools.Diagnostic.Kind;
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
public class NoPrivateTypesExported extends JavacTestingAbstractProcessor {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    59
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    60
    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
    61
        "javax.lang.model",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    62
        "javax.lang.model.element",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    63
        "javax.lang.model.type",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    64
        "javax.lang.model.util",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    65
    };
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 Set<String> javaxLangModelAcceptable;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    68
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    69
    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
    70
        "javax.annotation.processing",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    71
        "javax.tools",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    72
    };
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 Set<String> javaxToolsProcessingAcceptable;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    75
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    76
    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
    77
        "com.sun.source.doctree",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    78
        "com.sun.source.tree",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    79
        "com.sun.source.util"
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    80
    };
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
    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
    83
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    84
    static {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    85
        javaxLangModelAcceptable = new HashSet<>(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    86
            "java.io.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    87
            "java.lang.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    88
            "java.net.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    89
            "java.nio.",
33424
e6bd5406e2cf 8132096: Augment the Compiler Tree API to support the new Simplified Doclet API
ksrini
parents: 30730
diff changeset
    90
            "java.text.",
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    91
            "java.util.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    92
            "javax.lang.model.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    93
            "javax.annotation.processing.SupportedSourceVersion",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    94
            "jdk.Exported"
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    95
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    96
        Set<String> javaxToolsProcessingAcceptableTemp = new HashSet<>();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    97
        javaxToolsProcessingAcceptableTemp.addAll(javaxLangModelAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    98
        javaxToolsProcessingAcceptableTemp.addAll(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    99
                "javax.annotation.processing.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   100
                "javax.tools."
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   101
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   102
        javaxToolsProcessingAcceptable = javaxToolsProcessingAcceptableTemp;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   103
        Set<String> comSunSourceAcceptableTemp = new HashSet<>();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   104
        comSunSourceAcceptableTemp.addAll(javaxToolsProcessingAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   105
        comSunSourceAcceptableTemp.addAll(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   106
                "com.sun.source.doctree.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   107
                "com.sun.source.tree.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   108
                "com.sun.source.util."
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
        comSunSourceAcceptable = comSunSourceAcceptableTemp;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   111
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   112
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   113
    @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   114
    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
   115
                           RoundEnvironment roundEnv) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   116
        if (roundEnv.processingOver()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   117
            verifyPackage(javaxLangModelPackages, javaxLangModelAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   118
            verifyPackage(javaxToolsProcessingPackages, javaxToolsProcessingAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   119
            verifyPackage(comSunSourcePackages, comSunSourceAcceptable);
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
        return true;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   122
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   123
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   124
    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
   125
        for (String packageToTest : packagesToTest) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   126
            PackageElement packageElement = processingEnv.getElementUtils()
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   127
                    .getPackageElement(packageToTest);
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
            verifyReferredTypesAcceptable(packageElement, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   130
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   131
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   132
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   133
    private void verifyReferredTypesAcceptable(Element rootElement,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   134
                                               final Set<String> acceptable) {
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 21022
diff changeset
   135
        new ElementScanner<Void, Void>() {
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   136
            @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
   137
                verifyTypeAcceptable(e.getSuperclass(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   138
                verifyTypesAcceptable(e.getInterfaces(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   139
                scan(e.getTypeParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   140
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   141
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   142
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   143
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   144
            @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
   145
                verifyTypesAcceptable(e.getBounds(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   146
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   147
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   148
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   149
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   150
            @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
   151
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   152
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   153
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   154
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   155
            @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
   156
                verifyTypeAcceptable(e.asType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   157
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   158
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   159
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   160
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   161
            @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   162
            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
   163
                scan(e.getTypeParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   164
                verifyTypeAcceptable(e.getReturnType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   165
                scan(e.getParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   166
                verifyTypesAcceptable(e.getThrownTypes(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   167
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   168
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   169
                return null;
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
        }.scan(rootElement, null);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   172
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   173
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   174
    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
   175
                                   Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   176
        for (AnnotationMirror mirror : annotations) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   177
            Element annotationElement = mirror.getAnnotationType().asElement();
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
            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
   180
                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
   181
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   182
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   183
            verifyTypeAcceptable(mirror.getAnnotationType(), 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
            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
   186
                verifyAnnotationValue(value, acceptable);
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
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   189
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   190
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   191
    private void verifyAnnotationValue(AnnotationValue value,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   192
                                       final Set<String> acceptable) {
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 21022
diff changeset
   193
        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
   194
            @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
   195
                verifyTypeAcceptable(t, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   196
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   197
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   198
            @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   199
            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
   200
                verifyReferredTypesAcceptable(c, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   201
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   202
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   203
            @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
   204
                                             Void p) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   205
                for (AnnotationValue val : vals) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   206
                    val.accept(this, p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   207
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   208
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   209
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   210
            @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
   211
                error("Unexpected AnnotationValue: " + o.toString());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   212
                return super.defaultAction(o, p);
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
        }, null);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   215
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   216
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   217
    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
   218
                                       Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   219
        if (types == null) return ;
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
        for (TypeMirror type : types) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   222
            verifyTypeAcceptable(type, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   223
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   224
    }
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
    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
   227
        if (type == null) return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   228
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   229
        verifyAnnotations(type.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   230
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   231
        switch (type.getKind()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   232
            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
   233
            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
   234
                return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   235
            case DECLARED:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   236
                DeclaredType dt = (DeclaredType) type;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   237
                TypeElement outermostTypeElement = outermostTypeElement(dt.asElement());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   238
                String outermostType = outermostTypeElement.getQualifiedName().toString();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   239
                boolean isAcceptable = false;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   240
                for (String acceptablePackage : acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   241
                    if (outermostType.startsWith(acceptablePackage)) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   242
                        isAcceptable = true;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   243
                        break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   244
                    }
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
                if (!isAcceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   247
                    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
   248
                }
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
                for (TypeMirror bound : dt.getTypeArguments()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   251
                    verifyTypeAcceptable(bound, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   252
                }
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 ARRAY:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   255
                verifyTypeAcceptable(((ArrayType) type).getComponentType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   256
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   257
            case INTERSECTION:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   258
                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
   259
                    verifyTypeAcceptable(element, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   260
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   261
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   262
            case TYPEVAR:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   263
                verifyTypeAcceptable(((TypeVariable) type).getLowerBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   264
                verifyTypeAcceptable(((TypeVariable) type).getUpperBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   265
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   266
            case WILDCARD:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   267
                verifyTypeAcceptable(((WildcardType) type).getExtendsBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   268
                verifyTypeAcceptable(((WildcardType) type).getSuperBound(), acceptable);
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
            default:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   271
                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
   272
                break;
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
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   275
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   276
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   277
    private TypeElement outermostTypeElement(Element el) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   278
        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
   279
            el = el.getEnclosingElement();
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
        return (TypeElement) el;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   283
    }
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
    private void error(String text) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   286
        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
   287
    }
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
    private void note(String text) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   290
        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
   291
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   292
}