langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 29842 826ac2519523
child 36526 3b41f1c69604
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     1
/*
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     4
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     8
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    13
 * accompanied this code).
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    14
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    18
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    21
 * questions.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    22
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    23
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    24
/*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    25
 * @test
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    26
 * @bug 8013852 8031744
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    27
 * @summary Annotations on types
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    28
 * @library /tools/javac/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 29842
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 29842
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.code
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 29842
diff changeset
    31
 *          jdk.compiler/com.sun.tools.javac.processing
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 29842
diff changeset
    32
 *          jdk.compiler/com.sun.tools.javac.tree
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 29842
diff changeset
    33
 *          jdk.compiler/com.sun.tools.javac.util
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    34
 * @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    35
 * @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    36
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    37
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    38
import java.io.PrintWriter;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    39
import java.io.Serializable;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    40
import java.lang.annotation.Annotation;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    41
import java.lang.annotation.ElementType;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    42
import java.lang.annotation.Repeatable;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    43
import java.lang.annotation.Target;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    44
import java.util.ArrayList;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    45
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    46
import java.util.HashSet;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    47
import java.util.List;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    48
import java.util.Map;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    49
import java.util.NavigableMap;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    50
import java.util.Set;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    51
import java.util.TreeMap;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    52
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    53
import javax.annotation.processing.ProcessingEnvironment;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    54
import javax.annotation.processing.RoundEnvironment;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    55
import javax.lang.model.AnnotatedConstruct;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    56
import javax.lang.model.element.AnnotationMirror;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    57
import javax.lang.model.element.AnnotationValue;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    58
import javax.lang.model.element.Element;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    59
import javax.lang.model.element.ExecutableElement;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    60
import javax.lang.model.element.TypeElement;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    61
import javax.lang.model.type.ArrayType;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    62
import javax.lang.model.type.DeclaredType;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    63
import javax.lang.model.type.ExecutableType;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    64
import javax.lang.model.type.IntersectionType;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    65
import javax.lang.model.type.TypeMirror;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    66
import javax.lang.model.type.TypeVariable;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    67
import javax.lang.model.type.WildcardType;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    68
import javax.lang.model.util.Types;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    69
import javax.tools.Diagnostic.Kind;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    70
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    71
import com.sun.tools.javac.code.Attribute;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    72
import com.sun.tools.javac.code.Symbol;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    73
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    74
import com.sun.tools.javac.util.Name;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    75
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    76
import static com.sun.tools.javac.code.Attribute.Array;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    77
import static com.sun.tools.javac.code.Attribute.Constant;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    78
import static com.sun.tools.javac.code.Attribute.Compound;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    79
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    80
/**
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    81
 * The test scans this file looking for test cases annotated with @Test.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    82
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    83
public class BasicAnnoTests extends JavacTestingAbstractProcessor {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    84
    DPrinter dprinter;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    85
    PrintWriter out;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    86
    boolean verbose = true;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    87
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    88
    @Override
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    89
    public void init(ProcessingEnvironment pEnv) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    90
        super.init(pEnv);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    91
        dprinter = new DPrinter(((JavacProcessingEnvironment) pEnv).getContext());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    92
        out = dprinter.out;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    93
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    94
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    95
    @Override
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    96
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    97
        TestElementScanner s = new TestElementScanner();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    98
        for (Element e: roundEnv.getRootElements()) {
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
    99
            s.scan(e, null);
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   100
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   101
        return true;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   102
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   103
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   104
    void error(Element e, String msg) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   105
        messager.printMessage(Kind.ERROR, msg, e);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   106
        errors++;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   107
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   108
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   109
    int errors;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   110
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   111
    /**
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   112
     * Scan an element looking for declarations annotated with @Test.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   113
     * Run a TestTypeScanner on the annotations that are found.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   114
     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   115
    class TestElementScanner extends ElementScanner<Void,Void> {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   116
        public Void scan(Element elem, Void ignore) {
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   117
            List<AnnotationMirror> tests = new ArrayList<>();
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   118
            AnnotationMirror test = getAnnotation(elem, Test.class.getName().replace('$', '.'));
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   119
            if (test != null) {
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   120
                tests.add(test);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   121
            }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   122
            tests.addAll(getAnnotations(elem, Tests.class.getName().replace('$', '.')));
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   123
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   124
            if (tests.size() > 0) {
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   125
                out.println("Test: " + elem + " " + test);
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   126
                TestTypeScanner s = new TestTypeScanner(elem, tests, types);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   127
                s.test(elem.asType());
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   128
                out.println();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   129
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   130
            return super.scan(elem, ignore);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   131
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   132
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   133
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   134
    /**
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   135
     * Scan the type of an element, looking for an annotation
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   136
     * to match the expected annotation specified in the @Test annotation.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   137
     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   138
    class TestTypeScanner extends TypeScanner<Void, Void> {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   139
        Element elem;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   140
        NavigableMap<Integer, AnnotationMirror> toBeFound;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   141
        int count = 0;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   142
        Set<TypeMirror> seen = new HashSet<>();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   143
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   144
        TestTypeScanner(Element elem, List<AnnotationMirror> tests, Types types) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   145
            super(types);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   146
            this.elem = elem;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   147
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   148
            NavigableMap<Integer, AnnotationMirror> testByPos = new TreeMap<>();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   149
            for (AnnotationMirror test : tests) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   150
                for (int pos : getPosn(test)) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   151
                    testByPos.put(pos, test);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   152
                }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   153
            }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   154
            this.toBeFound = testByPos;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   155
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   156
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   157
        public void test(TypeMirror t) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   158
            scan(t, null);
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   159
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   160
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   161
        @Override
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   162
        Void scan(TypeMirror t, Void ignore) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   163
            if (t == null)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   164
                return DEFAULT_VALUE;
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   165
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   166
            if (!seen.contains(t)) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   167
                try {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   168
                    seen.add(t);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   169
                    if (verbose)
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   170
                        out.println("scan " + count + ": " + t);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   171
                    if (toBeFound.size() > 0) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   172
                        if (toBeFound.firstKey().equals(count)) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   173
                            AnnotationMirror test = toBeFound.pollFirstEntry().getValue();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   174
                            String annoType = getAnnoType(test);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   175
                            AnnotationMirror anno = getAnnotation(t, annoType);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   176
                            if (anno == null) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   177
                                error(elem, "annotation not found on " + count + ": " + t);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   178
                            } else {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   179
                                String v = getValue(anno, "value").toString();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   180
                                if (v.equals(getExpect(test))) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   181
                                    out.println("found " + anno + " as expected");
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   182
                                } else {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   183
                                    error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test));
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   184
                                }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   185
                            }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   186
                        } else if (count > toBeFound.firstKey()) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   187
                            rescue();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   188
                        } else {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   189
                            List<? extends AnnotationMirror> annos = t.getAnnotationMirrors();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   190
                            if (annos.size() > 0) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   191
                                for (AnnotationMirror a : annos)
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   192
                                    error(elem, "annotation " + a + " found on " + count + ": " + t);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   193
                            }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   194
                        }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   195
                    } else {
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   196
                        List<? extends AnnotationMirror> annos = t.getAnnotationMirrors();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   197
                        if (annos.size() > 0) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   198
                            for (AnnotationMirror a : annos)
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   199
                                error(elem, "annotation " + a + " found on " + count + ": " + t);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   200
                        }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   201
                    }
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   202
                    count++;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   203
                    return super.scan(t, ignore);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   204
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   205
                } finally {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   206
                    seen.remove(t);
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   207
                }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   208
            }
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   209
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   210
            return DEFAULT_VALUE;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   211
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   212
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   213
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   214
        private void rescue() {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   215
            while (toBeFound.size() > 0 && toBeFound.firstKey() >= count)
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   216
                toBeFound.pollFirstEntry();
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   217
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   218
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   219
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   220
    /** Get the position value from an element annotated with a @Test annotation mirror. */
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   221
    static int[] getPosn(Element elem) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   222
        return elem.getAnnotation(Test.class).posn();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   223
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   224
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   225
    /** Get the position value from a @Test annotation mirror. */
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   226
    static Integer[] getPosn(AnnotationMirror test) {
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   227
        AnnotationValue v = getValue(test, "posn");
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   228
        Object value = v.getValue();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   229
        Integer i = 0;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   230
        if (value instanceof Constant) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   231
            i = (Integer)((Constant)value).getValue();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   232
            Integer[] res = new Integer[1];
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   233
            res[0] = i;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   234
            return res;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   235
        } else if (value instanceof List) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   236
            List<Constant> l = (List<Constant>)value;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   237
            Integer[] res = new Integer[l.size()];
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   238
            for (int c = 0; c < l.size(); c++) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   239
                res[c] = (Integer)l.get(c).getValue();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   240
            }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   241
            return res;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   242
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   243
        return null;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   244
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   245
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   246
    /** Get the expect value from an @Test annotation mirror. */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   247
    static String getExpect(AnnotationMirror test) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   248
        AnnotationValue v = getValue(test, "expect");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   249
        return (String) v.getValue();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   250
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   251
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   252
    /** Get the annoType value from an @Test annotation mirror. */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   253
    static String getAnnoType(AnnotationMirror test) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   254
        AnnotationValue v = getValue(test, "annoType");
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   255
        TypeMirror m = (TypeMirror) v.getValue();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   256
        return m.toString();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   257
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   258
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   259
    /**
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   260
     * Get a specific annotation mirror from an annotated construct.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   261
     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   262
    static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   263
        for (AnnotationMirror m: e.getAnnotationMirrors()) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   264
            TypeElement te = (TypeElement) m.getAnnotationType().asElement();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   265
            if (te.getQualifiedName().contentEquals(name)) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   266
                return m;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   267
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   268
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   269
        return null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   270
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   271
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   272
    static List<AnnotationMirror> getAnnotations(Element e, String name) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   273
        Name valueName = ((Symbol)e).getSimpleName().table.names.value;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   274
        List<AnnotationMirror> res = new ArrayList<>();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   275
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   276
        for (AnnotationMirror m : e.getAnnotationMirrors()) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   277
            TypeElement te = (TypeElement) m.getAnnotationType().asElement();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   278
            if (te.getQualifiedName().contentEquals(name)) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   279
                Compound theAnno = (Compound)m;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   280
                Array valueArray = (Array)theAnno.member(valueName);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   281
                for (Attribute a : valueArray.getValue()) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   282
                    AnnotationMirror theMirror = (AnnotationMirror) a;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   283
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   284
                    res.add(theMirror);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   285
                }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   286
            }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   287
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   288
        return res;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   289
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   290
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   291
    /**
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   292
     * Get a specific value from an annotation mirror.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   293
     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   294
    static AnnotationValue getValue(AnnotationMirror anno, String name) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   295
        Map<? extends ExecutableElement, ? extends AnnotationValue> map = anno.getElementValues();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   296
        for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> e: map.entrySet()) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   297
            if (e.getKey().getSimpleName().contentEquals(name)) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   298
                return e.getValue();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   299
            }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   300
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   301
        return null;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   302
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   303
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   304
    /**
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   305
     * The Language Model API does not provide a type scanner, so provide
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   306
     * one sufficient for our needs.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   307
     */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   308
    static class TypeScanner<R, P> extends SimpleTypeVisitor<R, P> {
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   309
        private Types types;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   310
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   311
        public TypeScanner(Types types) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   312
            super();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   313
            this.types = types;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   314
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   315
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   316
        @Override
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   317
        public R visitArray(ArrayType t, P p) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   318
            scan(t.getComponentType(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   319
            return super.visitArray(t, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   320
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   321
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   322
        @Override
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   323
        public R visitExecutable(ExecutableType t, P p) {
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   324
            //out.println("  type parameters: " + t.getTypeVariables());
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   325
            scan(t.getTypeVariables(), p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   326
            //out.println("  return: " + t.getReturnType());
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   327
            scan(t.getReturnType(), p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   328
            //out.println("  receiver: " + t.getReceiverTypes());
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   329
            scan(t.getReceiverType());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   330
            //out.println("  params: " + t.getParameterTypes());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   331
            scan(t.getParameterTypes(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   332
            //out.println("  throws: " + t.getThrownTypes());
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   333
            scan(t.getThrownTypes(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   334
            return super.visitExecutable(t, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   335
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   336
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   337
        @Override
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   338
        public R visitDeclared(DeclaredType t, P p) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   339
            scan(t.getTypeArguments(), p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   340
            // don't scan enclosing
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   341
            scan(types.directSupertypes(t), p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   342
            return super.visitDeclared(t, p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   343
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   344
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   345
        @Override
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   346
        public R visitIntersection(IntersectionType t, P p) {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   347
            scan(t.getBounds(), p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   348
            return super.visitIntersection(t, p);
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   349
        }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   350
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   351
        @Override
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   352
        public R visitTypeVariable(TypeVariable t, P p) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   353
            scan(t.getLowerBound(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   354
            scan(t.getUpperBound(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   355
            return super.visitTypeVariable(t, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   356
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   357
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   358
        @Override
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   359
        public R visitWildcard(WildcardType t, P p) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   360
            scan(t.getExtendsBound(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   361
            scan(t.getSuperBound(), p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   362
            return super.visitWildcard(t, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   363
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   364
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   365
        R scan(TypeMirror t) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   366
            return scan(t, null);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   367
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   368
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   369
        R scan(TypeMirror t, P p) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   370
            return (t == null) ? DEFAULT_VALUE : t.accept(this, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   371
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   372
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   373
        R scan(Iterable<? extends TypeMirror> iter, P p) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   374
            if (iter == null)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   375
                return DEFAULT_VALUE;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   376
            R result = DEFAULT_VALUE;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   377
            for (TypeMirror t: iter)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   378
                result = scan(t, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   379
            return result;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   380
        }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   381
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   382
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   383
    /** Annotation to identify test cases. */
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   384
    @Repeatable(Tests.class)
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   385
    @interface Test {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   386
        /** Where to look for the annotation, expressed as a scan index. */
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   387
        int[] posn();
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   388
        /** The annotation to look for. */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   389
        Class<? extends Annotation> annoType();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   390
        /** The string representation of the annotation's value. */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   391
        String expect();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   392
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   393
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   394
    @interface Tests {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   395
        Test[] value();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   396
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   397
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   398
    /** Type annotation to use in test cases. */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   399
    @Target(ElementType.TYPE_USE)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   400
    public @interface TA {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   401
        int value();
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   402
    }
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   403
    @Target(ElementType.TYPE_USE)
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   404
    public @interface TB {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   405
        int value();
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   406
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   407
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   408
    // Test cases
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   409
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   410
    // TODO: add more cases for arrays
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   411
    //       all annotated
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   412
    //       all but one annotated
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   413
    //             vary position of one not annotated
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   414
    //       only one annotated
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   415
    //             vary position of one annotated
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   416
    //       the three above with the corner case of the ambiguos decl + type anno added
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   417
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   418
    @Test(posn=0, annoType=TA.class, expect="1")
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   419
    public @TA(1) int f1;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   420
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   421
    @Test(posn=0, annoType=TA.class, expect="11")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   422
    @TA(11) public int f11;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   423
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   424
    @Test(posn=1, annoType=TA.class, expect="111")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   425
    @TA(111) public int [] f111;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   426
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   427
    @Test(posn=1, annoType=TA.class, expect="1120")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   428
    @Test(posn=0, annoType=TB.class, expect="1121")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   429
    @TA(1120) public int @TB(1121) [] f112;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   430
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   431
    @Test(posn=0, annoType=TB.class, expect="11211")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   432
    @Test(posn=1, annoType=TA.class, expect="11200")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   433
    public @TA(11200) int @TB(11211) [] f112b;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   434
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   435
    @Test(posn=1, annoType=TB.class, expect="1131")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   436
    @Test(posn=2, annoType=TA.class, expect="1130")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   437
    @TA(1130) public int [] @TB(1131) [] f113;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   438
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   439
    @Test(posn=5, annoType=TA.class, expect="12")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   440
    public @TA(12) int [] [] [] [] [] f12;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   441
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   442
    @Test(posn=6, annoType=TA.class, expect="13")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   443
    public @TA(13) int [] [] [] [] [] [] f13;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   444
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   445
    @Test(posn=7, annoType=TA.class, expect="14")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   446
    @TA(14) public int [] [] [] [] [] [] [] f14;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   447
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   448
    @Test(posn=6, annoType=TA.class, expect="150")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   449
    @Test(posn=7, annoType=TB.class, expect="151")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   450
    @TB(151) public int [] [] [] [] [] [] @TA(150) [] f15;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   451
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   452
    @Test(posn=0, annoType=TB.class, expect="1511")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   453
    @Test(posn=3, annoType=TA.class, expect="1512")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   454
    @Test(posn=6, annoType=TA.class, expect="150")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   455
    @Test(posn=7, annoType=TB.class, expect="151")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   456
    @TB(151) public int @TB(1511) [] [] [] @TA(1512) [] [] [] @TA(150) [] f15b;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   457
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   458
    @Test(posn=0, annoType=TB.class, expect="1521")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   459
    @Test(posn=3, annoType=TA.class, expect="1522")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   460
    @Test(posn=6, annoType=TA.class, expect="152")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   461
    public int @TB(1521) [] [] [] @TA(1522) [] [] [] @TA(152) [] f15c;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   462
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   463
    @Test(posn=5, annoType=TA.class, expect="160")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   464
    @Test(posn=6, annoType=TB.class, expect="161")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   465
    public int [] [] [] [] [] @TA(160) [] @TB(161) [] f16;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   466
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   467
    @Test(posn=0, annoType=TA.class, expect="2")
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   468
    public int @TA(2) [] f2;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   469
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   470
    @Test(posn=0, annoType=TB.class, expect="33")
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   471
    @Test(posn=1, annoType=TA.class, expect="3")
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   472
    public @TA(3) int @TB(33) [] f3;
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   473
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   474
    @Test(posn=2, annoType=TA.class, expect="4")
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   475
    public int m1(@TA(4) float a) throws Exception { return 0; }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   476
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   477
    @Test(posn=1, annoType=TA.class, expect="5")
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   478
    public @TA(5) int m2(float a) throws Exception { return 0; }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   479
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   480
    @Test(posn=3, annoType=TA.class, expect="6")
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   481
    public int m3(float a) throws @TA(6) Exception { return 0; }
29842
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   482
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   483
    // Also tests that a decl anno on a typevar doesn't show up on the Type
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   484
    @Test(posn=7, annoType=TA.class, expect="8")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   485
    public <@TA(7) M> M m4(@TA(8) float a) throws Exception { return null; }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   486
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   487
    // Also tests that a decl anno on a typevar doesn't show up on the Type
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   488
    @Test(posn=4, annoType=TA.class, expect="10")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   489
    public class Inner1<@TA(9) S> extends @TA(10) Object implements Cloneable {}
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   490
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   491
    // Also tests that a decl anno on a typevar doesn't show up on the Type
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   492
    @Test(posn=5, annoType=TA.class, expect="12")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   493
    public class Inner2<@TA(11) S> extends Object implements @TA(12) Cloneable {}
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   494
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   495
    @Test(posn={3,6}, annoType=TA.class, expect="13")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   496
    public <M extends @TA(13) Object> M m5(float a) { return null; }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   497
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   498
    @Test(posn=3, annoType=TA.class, expect="14")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   499
    public class Inner3<QQQ extends @TA(14) Map> {}
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   500
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   501
    @Test(posn=4, annoType=TA.class, expect="15")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   502
    public class Inner4<T extends @TA(15) Object & Cloneable & Serializable> {}
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   503
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   504
    @Test(posn=5, annoType=TA.class, expect="16")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   505
    public class Inner5<T extends Object & @TA(16) Cloneable & Serializable> {}
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   506
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   507
    @Test(posn=7, annoType=TA.class, expect="17")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   508
    public class Inner6<T extends Object & Cloneable & @TA(17) Serializable> {}
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   509
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   510
    // Test annotated bounds
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   511
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   512
    @Test(posn=1, annoType=TA.class, expect="18")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   513
    public Set<@TA(18) ? extends Object> f4;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   514
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   515
    @Test(posn=2, annoType=TA.class, expect="19")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   516
    public Set<? extends @TA(19) Object> f5;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   517
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   518
    @Test(posn=3, annoType=TA.class, expect="20")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   519
    public Set<? extends Set<@TA(20) ? extends Object>> f6;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   520
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   521
    @Test(posn=4, annoType=TA.class, expect="21")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   522
    public Set<? extends Set<? extends @TA(21) Object>> f7;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   523
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   524
    @Test(posn=1, annoType=TA.class, expect="22")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   525
    public Set<@TA(22) ?> f8;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   526
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   527
    @Test(posn=1, annoType=TA.class, expect="23")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   528
    public Set<@TA(23) ? super Object> f9;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   529
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   530
    // Test type use annotations on uses of type variables
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   531
    @Test(posn=5, annoType = TA.class, expect = "25")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   532
    @Test(posn=5, annoType = TB.class, expect = "26")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   533
    <T> void m6(@TA(25) @TB(26) T t) { }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   534
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   535
    class Inner7<T> {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   536
        @Test(posn=0, annoType = TA.class, expect = "30")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   537
        @Test(posn=0, annoType = TB.class, expect = "31")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   538
        @TA(30) @TB(31) T f;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   539
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   540
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   541
    // Test type use annotations on uses of type variables
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   542
    @Test(posn=5, annoType = TB.class, expect = "41")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   543
    <@TA(40) T> void m7(@TB(41) T t) { }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   544
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   545
    class Inner8<@TA(50) T> {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   546
        @Test(posn=0, annoType = TB.class, expect = "51")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   547
        @TB(51) T f;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   548
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   549
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   550
    // Test type use annotations on uses of Class types
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   551
    @Test(posn=5, annoType = TA.class, expect = "60")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   552
    @Test(posn=5, annoType = TB.class, expect = "61")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   553
    <T> void m60(@TA(60) @TB(61) String t) { }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   554
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   555
    class Inner70<T> {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   556
        @Test(posn=0, annoType = TA.class, expect = "70")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   557
        @Test(posn=0, annoType = TB.class, expect = "71")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   558
        @TA(70) @TB(71) String f;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   559
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   560
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   561
    // Test type use annotations on uses of type variables
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   562
    @Test(posn=5, annoType = TB.class, expect = "81")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   563
    <@TA(80) T> void m80(@TB(81) String t) { }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   564
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   565
    class Inner90<@TA(90) T> {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   566
        @Test(posn=0, annoType = TB.class, expect = "91")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   567
        @TB(91) String f;
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   568
    }
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   569
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   570
    // Recursive bound
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   571
    @Test(posn=4, annoType = TB.class, expect = "100")
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   572
    class Inner100<T extends Inner100<@TB(100) T>> {
826ac2519523 8031744: Annotations on many Language Model elements are not returned
jjg
parents: 26532
diff changeset
   573
    }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   574
}