test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassExtends.java

Tue, 12 Mar 2013 17:39:34 +0100

author
jfranck
date
Tue, 12 Mar 2013 17:39:34 +0100
changeset 1629
f427043f8c65
parent 1534
bec996065c45
child 2227
998b10c43157
permissions
-rw-r--r--

7196531: Duplicate error messages on repeating annotations
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    26 /*
    27  * @test
    28  * @summary Test population of reference info for class extends clauses
    29  * @compile -g Driver.java ReferenceInfoUtil.java ClassExtends.java
    30  * @run main Driver ClassExtends
    31  */
    32 public class ClassExtends {
    34     @TADescriptions({
    35         @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1),
    36         @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
    37     })
    38     public String regularClass() {
    39         return "class Test extends @TA Object implements Cloneable, @TB Runnable {"
    40                + "  public void run() { } }";
    41     }
    43     @TADescriptions({
    44         @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
    45                 genericLocation = { 3, 0 }),
    46         @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
    47                 genericLocation  = { 3, 1 })
    48     })
    49     public String regularClassExtendsParametrized() {
    50         return "class Test extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
    51     }
    53     @TADescriptions({
    54         @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1),
    55         @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
    56     })
    57     public String abstractClass() {
    58         return "abstract class Test extends @TA Date implements Cloneable, @TB Runnable {"
    59                + "  public void run() { } }";
    60     }
    62     @TADescriptions({
    63         @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
    64                 genericLocation = { 3, 0 }),
    65         @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
    66                 genericLocation  = { 3, 1 })
    67     })
    68     public String abstractClassExtendsParametrized() {
    69         return "abstract class Test extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
    70     }
    72     @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
    73     public String regularInterface() {
    74         return "interface Test extends Cloneable, @TB Runnable { }";
    75     }
    77     @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
    78             genericLocation  = { 3, 1 })
    79     public String regularInterfaceExtendsParametrized() {
    80         return "interface Test extends Cloneable, Map<String, @TB String>{ } ";
    81     }
    83     @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
    84     public String regularEnum() {
    85         return "enum Test implements Cloneable, @TB Runnable { TEST; public void run() { } }";
    86     }
    88     @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
    89             genericLocation  = { 3, 0 })
    90     public String regularEnumExtendsParametrized() {
    91         return
    92             "enum Test implements Cloneable, Comparator<@TB String> { TEST;  "
    93             + "public int compare(String a, String b) { return 0; }}";
    94     }
    96 }

mercurial