langtools/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 25009 55c823e853f2
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:
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 25009
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     4
 *
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     8
 *
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    13
 * accompanied this code).
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    14
 *
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    18
 *
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    21
 * questions.
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    22
 */
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    23
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    24
/*
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    25
 * @test
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    26
 * @bug 8011027 8046916
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    27
 * @library /tools/javac/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 25009
diff changeset
    28
 * @modules java.compiler
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 25009
diff changeset
    29
 *          jdk.compiler
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    30
 * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    31
 * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    32
 */
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    33
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    34
import java.util.*;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    35
import java.lang.annotation.*;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    36
import javax.annotation.processing.*;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    37
import javax.lang.model.element.*;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    38
import javax.tools.*;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    39
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    40
@ExpectedTypeParameterAnnotations(typeParameterName="T1",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    41
                                  annotations={"Foo1", "Bar1", "Baz1"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    42
@ExpectedTypeParameterAnnotations(typeParameterName="T2", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    43
@ExpectedTypeParameterAnnotations(typeParameterName="T3",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    44
                                  annotations={"Foo2", "Bar2", "Baz2"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    45
@ExpectedTypeParameterAnnotations(typeParameterName="T4", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    46
public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2 @Baz2 T3, T4> extends
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    47
        JavacTestingAbstractProcessor {
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    48
    int round = 0;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    49
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    50
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    51
        if (++round == 1) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    52
            int found = (new Scanner()).scan(roundEnv.getRootElements(), null);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    53
            if (found == expect) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    54
                ; //nop
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    55
            } else {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    56
                error("unexpected number of results: expected " + expect
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    57
                        + ", found " + found);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    58
            }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    59
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    60
        }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    61
        return true;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    62
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    63
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    64
    class Scanner extends JavacTestingAbstractProcessor.ElementScanner<Integer,Void> {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    65
        @Override
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    66
        public Integer visitExecutable(ExecutableElement e, Void p) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    67
            super.visitExecutable(e, p);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    68
            found += check(e, e.getTypeParameters());
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    69
            return found;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    70
        }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    71
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    72
        @Override
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    73
        public Integer visitType(TypeElement e, Void p) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    74
            super.visitType(e, p);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    75
            found += check(e, e.getTypeParameters());
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    76
            return found;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    77
        }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    78
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    79
        int found;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    80
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    81
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    82
    int check(Element e, List<? extends TypeParameterElement> typarams) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    83
        if (typarams.isEmpty())
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    84
            return 0;
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
    85
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    86
        for (TypeParameterElement tpe : typarams) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    87
            ExpectedTypeParameterAnnotations expected = null;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    88
            for (ExpectedTypeParameterAnnotations a : e.getAnnotationsByType(ExpectedTypeParameterAnnotations.class)) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    89
                if (tpe.getSimpleName().contentEquals(a.typeParameterName())) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    90
                    expected = a;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    91
                    break;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    92
                }
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    93
            }
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    94
            if (expected == null) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    95
                throw new IllegalStateException("Does not have expected values annotation.");
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    96
            }
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    97
            checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors(), expected);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    98
            checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe), expected);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
    99
            checkGetAnnotation(tpe, expected);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   100
            checkGetAnnotations(tpe, expected);
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   101
        }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   102
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   103
        return typarams.size();
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   104
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   105
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   106
    void checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l, ExpectedTypeParameterAnnotations expected) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   107
        String[] expectedAnnotations = expected.annotations();
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   108
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   109
        if (l.size() != expectedAnnotations.length) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   110
            error("Incorrect number of annotations, got " + l.size() +
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   111
                    ", should be " + expectedAnnotations.length, tpe);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   112
            return ;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   113
        }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   114
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   115
        for (int i = 0; i < expectedAnnotations.length; i++) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   116
            AnnotationMirror m = l.get(i);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   117
            if (!m.getAnnotationType().asElement().equals(elements.getTypeElement(expectedAnnotations[i]))) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   118
                error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   119
                return ;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   120
            }
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   121
        }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   122
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   123
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   124
    void checkGetAnnotation(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   125
        List<String> expectedAnnotations = Arrays.asList(expected.annotations());
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   126
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   127
        for (Class<? extends Annotation> c : ALL_ANNOTATIONS) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   128
            Object a = tpe.getAnnotation(c);
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   129
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   130
            if (a != null ^ expectedAnnotations.indexOf(c.getName()) != (-1)) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   131
                error("Unexpected behavior for " + c.getName(), tpe);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   132
                return ;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   133
            }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   134
        }
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   135
    }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   136
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   137
    void checkGetAnnotations(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   138
        List<String> expectedAnnotations = Arrays.asList(expected.annotations());
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   139
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   140
        for (Class<? extends Annotation> c : ALL_ANNOTATIONS) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   141
            Object[] a = tpe.getAnnotationsByType(c);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   142
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   143
            if (a.length > 0 ^ expectedAnnotations.indexOf(c.getName()) != (-1)) {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   144
                error("Unexpected behavior for " + c.getName(), tpe);
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   145
                return ;
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   146
            }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   147
        }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   148
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   149
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   150
    void note(String msg) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   151
        messager.printMessage(Diagnostic.Kind.NOTE, msg);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   152
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   153
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   154
    void note(String msg, Element e) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   155
        messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   156
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   157
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   158
    void error(String msg, Element e) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   159
        messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   160
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   161
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   162
    void error(String msg) {
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   163
        messager.printMessage(Diagnostic.Kind.ERROR, msg);
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   164
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   165
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   166
    Class<? extends Annotation>[] ALL_ANNOTATIONS = new Class[] {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   167
        Foo1.class, Bar1.class, Baz1.class,
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   168
        Foo2.class, Bar2.class, Baz2.class,
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   169
    };
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   170
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   171
    // additional generic elements to test
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   172
    @ExpectedTypeParameterAnnotations(typeParameterName="W",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   173
                                      annotations={"Foo1", "Bar1", "Baz1"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   174
    @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   175
    @ExpectedTypeParameterAnnotations(typeParameterName="Y",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   176
                                      annotations={"Foo2", "Bar2", "Baz2"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   177
    @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   178
    <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> X m(X x) { return x; }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   179
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   180
    @ExpectedTypeParameterAnnotations(typeParameterName="W",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   181
                                      annotations={"Foo1", "Bar1", "Baz1"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   182
    @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   183
    @ExpectedTypeParameterAnnotations(typeParameterName="Y",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   184
                                      annotations={"Foo2", "Bar2", "Baz2"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   185
    @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   186
    interface Intf<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { X m() ; }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   187
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   188
    @ExpectedTypeParameterAnnotations(typeParameterName="W",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   189
                                      annotations={"Foo1", "Bar1", "Baz1"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   190
    @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   191
    @ExpectedTypeParameterAnnotations(typeParameterName="Y",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   192
                                      annotations={"Foo2", "Bar2", "Baz2"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   193
    @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   194
    class Clazz<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   195
        @ExpectedTypeParameterAnnotations(typeParameterName="W",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   196
                                          annotations={"Foo1", "Bar1", "Baz1"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   197
        @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   198
        @ExpectedTypeParameterAnnotations(typeParameterName="Y",
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   199
                                          annotations={"Foo2", "Bar2", "Baz2"})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   200
        @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   201
        <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> Clazz() { }
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   202
    }
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   203
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   204
    final int expect = 5 * 4;  // top level class, plus preceding examples, 4 type variables each
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   205
}
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   206
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   207
@Target(ElementType.TYPE_PARAMETER)
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   208
@interface Foo1 {}
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   209
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   210
@Target(ElementType.TYPE_PARAMETER)
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   211
@interface Bar1 {}
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   212
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   213
@Target(ElementType.TYPE_PARAMETER)
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   214
@interface Baz1 {}
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   215
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   216
@Target(ElementType.TYPE_PARAMETER)
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   217
@interface Foo2 {}
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   218
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   219
@Target(ElementType.TYPE_PARAMETER)
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   220
@interface Bar2 {}
17278
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   221
a48ec76f26e9 8011027: Type parameter annotations not passed through to javax.lang.model
jfranck
parents:
diff changeset
   222
@Target(ElementType.TYPE_PARAMETER)
25009
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   223
@interface Baz2 {}
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   224
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   225
@Repeatable(ExpectedTypeParameterAnnotationsCollection.class)
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   226
@interface ExpectedTypeParameterAnnotations {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   227
    public String typeParameterName();
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   228
    public String[] annotations();
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   229
}
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   230
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   231
@interface ExpectedTypeParameterAnnotationsCollection {
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   232
    public ExpectedTypeParameterAnnotations[] value();
55c823e853f2 8046916: Type parameter annotations don't work with multiple type parameters
jlahoda
parents: 17278
diff changeset
   233
}