test/langtools/tools/javac/tree/NoPrivateTypesExported.java
author jlahoda
Mon, 21 Oct 2019 15:38:26 +0200
changeset 58713 ad69fd32778e
parent 47482 4a35a00eb001
permissions -rw-r--r--
8226585: Improve javac messages for using a preview API Summary: Avoiding deprecation for removal for APIs associated with preview features, the features are marked with an annotation, and errors/warnings are produced for them based on the annotation. Reviewed-by: erikj, mcimadamore, alanb Contributed-by: joe.darcy@oracle.com, jan.lahoda@oracle.com
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.",
34916
16043fc1d90b 8049422: Remove @jdk.Exported
alanb
parents: 33424
diff changeset
    93
            "javax.annotation.processing.SupportedSourceVersion"
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    94
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    95
        Set<String> javaxToolsProcessingAcceptableTemp = new HashSet<>();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    96
        javaxToolsProcessingAcceptableTemp.addAll(javaxLangModelAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    97
        javaxToolsProcessingAcceptableTemp.addAll(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    98
                "javax.annotation.processing.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
    99
                "javax.tools."
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   100
        ));
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   101
        javaxToolsProcessingAcceptable = javaxToolsProcessingAcceptableTemp;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   102
        Set<String> comSunSourceAcceptableTemp = new HashSet<>();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   103
        comSunSourceAcceptableTemp.addAll(javaxToolsProcessingAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   104
        comSunSourceAcceptableTemp.addAll(Arrays.asList(
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   105
                "com.sun.source.doctree.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   106
                "com.sun.source.tree.",
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   107
                "com.sun.source.util."
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
        comSunSourceAcceptable = comSunSourceAcceptableTemp;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   110
    }
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
    @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   113
    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
   114
                           RoundEnvironment roundEnv) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   115
        if (roundEnv.processingOver()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   116
            verifyPackage(javaxLangModelPackages, javaxLangModelAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   117
            verifyPackage(javaxToolsProcessingPackages, javaxToolsProcessingAcceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   118
            verifyPackage(comSunSourcePackages, comSunSourceAcceptable);
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
        return true;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   121
    }
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
    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
   124
        for (String packageToTest : packagesToTest) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   125
            PackageElement packageElement = processingEnv.getElementUtils()
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   126
                    .getPackageElement(packageToTest);
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
            verifyReferredTypesAcceptable(packageElement, acceptable);
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
    }
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
    private void verifyReferredTypesAcceptable(Element rootElement,
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   133
                                               final Set<String> acceptable) {
25690
b1dac768ab79 8050430: Provided new utility visitors supporting SourceVersion.RELEASE_9
darcy
parents: 21022
diff changeset
   134
        new ElementScanner<Void, Void>() {
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   135
            @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
   136
                verifyTypeAcceptable(e.getSuperclass(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   137
                verifyTypesAcceptable(e.getInterfaces(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   138
                scan(e.getTypeParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   139
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   140
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   141
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   142
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   143
            @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
   144
                verifyTypesAcceptable(e.getBounds(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   145
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   146
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   147
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   148
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   149
            @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
   150
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   151
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   152
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   153
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   154
            @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
   155
                verifyTypeAcceptable(e.asType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   156
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   157
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   158
                return null;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   159
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   160
            @Override
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   161
            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
   162
                scan(e.getTypeParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   163
                verifyTypeAcceptable(e.getReturnType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   164
                scan(e.getParameters(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   165
                verifyTypesAcceptable(e.getThrownTypes(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   166
                scan(e.getEnclosedElements(), p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   167
                verifyAnnotations(e.getAnnotationMirrors(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   168
                return 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
        }.scan(rootElement, null);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   171
    }
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
    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
   174
                                   Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   175
        for (AnnotationMirror mirror : annotations) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   176
            Element annotationElement = mirror.getAnnotationType().asElement();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   177
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   178
            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
   179
                note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
58713
ad69fd32778e 8226585: Improve javac messages for using a preview API
jlahoda
parents: 47482
diff changeset
   180
                continue;
21022
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
            }
47482
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   210
            @Override public Void visitBoolean(boolean b, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   211
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   212
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   213
            @Override public Void visitByte(byte b, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   214
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   215
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   216
            @Override public Void visitChar(char c, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   217
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   218
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   219
            @Override public Void visitDouble(double d, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   220
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   221
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   222
            @Override public Void visitFloat(float f, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   223
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   224
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   225
            @Override public Void visitInt(int i, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   226
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   227
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   228
            @Override public Void visitLong(long i, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   229
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   230
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   231
            @Override public Void visitShort(short s, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   232
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   233
            }
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   234
            @Override public Void visitString(String s, Void p) {
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   235
                return null;
4a35a00eb001 8190315: Test tools/javac/tree/NoPrivateTypesExported.java failing
jlahoda
parents: 47216
diff changeset
   236
            }
21022
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   237
            @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
   238
                error("Unexpected AnnotationValue: " + o.toString());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   239
                return super.defaultAction(o, p);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   240
            }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   241
        }, null);
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
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   244
    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
   245
                                       Set<String> acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   246
        if (types == null) return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   247
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   248
        for (TypeMirror type : types) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   249
            verifyTypeAcceptable(type, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   250
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   251
    }
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
    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
   254
        if (type == null) return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   255
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   256
        verifyAnnotations(type.getAnnotationMirrors(), 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
        switch (type.getKind()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   259
            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
   260
            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
   261
                return ;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   262
            case DECLARED:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   263
                DeclaredType dt = (DeclaredType) type;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   264
                TypeElement outermostTypeElement = outermostTypeElement(dt.asElement());
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   265
                String outermostType = outermostTypeElement.getQualifiedName().toString();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   266
                boolean isAcceptable = false;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   267
                for (String acceptablePackage : acceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   268
                    if (outermostType.startsWith(acceptablePackage)) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   269
                        isAcceptable = true;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   270
                        break;
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
                if (!isAcceptable) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   274
                    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
   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
                for (TypeMirror bound : dt.getTypeArguments()) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   278
                    verifyTypeAcceptable(bound, acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   279
                }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   280
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   281
            case ARRAY:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   282
                verifyTypeAcceptable(((ArrayType) type).getComponentType(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   283
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   284
            case INTERSECTION:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   285
                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
   286
                    verifyTypeAcceptable(element, acceptable);
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
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   289
            case TYPEVAR:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   290
                verifyTypeAcceptable(((TypeVariable) type).getLowerBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   291
                verifyTypeAcceptable(((TypeVariable) type).getUpperBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   292
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   293
            case WILDCARD:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   294
                verifyTypeAcceptable(((WildcardType) type).getExtendsBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   295
                verifyTypeAcceptable(((WildcardType) type).getSuperBound(), acceptable);
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   296
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   297
            default:
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   298
                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
   299
                break;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   300
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   301
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   302
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   303
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   304
    private TypeElement outermostTypeElement(Element el) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   305
        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
   306
            el = el.getEnclosingElement();
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   307
        }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   308
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   309
        return (TypeElement) el;
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   310
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   311
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   312
    private void error(String text) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   313
        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
   314
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   315
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   316
    private void note(String text) {
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   317
        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
   318
    }
08da1099cba7 8026180: com.sun.source.tree.NewArrayTree refers to com.sun.tools.javac.util.List
jlahoda
parents:
diff changeset
   319
}