langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassExtends.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 24896 986d876a9121
child 30846 2b3f379840f0
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:
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24896
diff changeset
     2
 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     4
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     8
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    13
 * accompanied this code).
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    14
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    18
 *
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    21
 * questions.
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    22
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    23
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    24
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    25
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    26
/*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    27
 * @test
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    28
 * @bug 8042451
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    29
 * @summary Test population of reference info for class extends clauses
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24896
diff changeset
    30
 * @modules jdk.compiler/com.sun.tools.classfile
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    31
 * @compile -g Driver.java ReferenceInfoUtil.java ClassExtends.java
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    32
 * @run main Driver ClassExtends
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    33
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    34
public class ClassExtends {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    35
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    36
    @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    37
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    38
    public String regularClass() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    39
        return "class %TEST_CLASS_NAME% extends @TA Object implements Cloneable, @TB Runnable {"
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    40
               + "  public void run() { } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    41
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    42
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    43
    @TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    44
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    45
    public String regularClassRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    46
        return "class %TEST_CLASS_NAME% extends @RTA @RTA Object implements Cloneable, @RTB @RTB Runnable {"
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    47
                + "  public void run() { } }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    48
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    49
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    50
    @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    51
            genericLocation = { 3, 0 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    52
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    53
            genericLocation  = { 3, 1 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    54
    public String regularClassExtendsParametrized() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    55
        return "class %TEST_CLASS_NAME% extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    56
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    57
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    58
    @TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    59
            genericLocation = { 3, 0 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    60
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    61
            genericLocation  = { 3, 1 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    62
    public String regularClassExtendsParametrizedRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    63
        return "class %TEST_CLASS_NAME% extends HashMap<@RTA @RTA String, String> implements Cloneable, Map<String, @RTB @RTB String>{ } ";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    64
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    65
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    66
    @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    67
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    68
    public String abstractClass() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    69
        return "abstract class %TEST_CLASS_NAME% extends @TA Date implements Cloneable, @TB Runnable {"
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    70
               + "  public void run() { } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    71
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    72
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    73
    @TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    74
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    75
    public String abstractClassRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    76
        return "abstract class %TEST_CLASS_NAME% extends @RTA @RTA Date implements Cloneable, @RTB @RTB Runnable {"
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    77
                + "  public void run() { } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    78
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    79
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    80
    @TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = -1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    81
            genericLocation = { 3, 0 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    82
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    83
            genericLocation  = { 3, 1 })
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    84
    public String abstractClassExtendsParametrized() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    85
        return "abstract class %TEST_CLASS_NAME% extends HashMap<@RTA @RTA String, String> implements Cloneable, Map<String, @RTB @RTB String>{ } ";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    86
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    87
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    88
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    89
    public String regularInterface() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    90
        return "interface %TEST_CLASS_NAME% extends Cloneable, @TB Runnable { }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    91
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    92
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    93
    @TADescription(annotation = "RTAs", type = CLASS_EXTENDS, typeIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    94
    public String regularInterfaceRepetableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
    95
        return "interface %TEST_CLASS_NAME% extends Cloneable, @RTA @RTA Runnable { }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    96
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    97
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    98
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    99
            genericLocation  = { 3, 1 })
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   100
    public String regularInterfaceExtendsParametrized() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   101
        return "interface %TEST_CLASS_NAME% extends Cloneable, Map<String, @TB String>{ } ";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   102
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   103
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   104
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   105
            genericLocation  = { 3, 1 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   106
    public String regularInterfaceExtendsParametrizedRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   107
        return "interface %TEST_CLASS_NAME% extends Cloneable, Map<String, @RTB @RTB String>{ } ";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   108
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   109
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   110
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   111
    public String regularEnum() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   112
        return "enum %TEST_CLASS_NAME% implements Cloneable, @TB Runnable { TEST; public void run() { } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   113
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   114
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   115
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   116
    public String regularEnumRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   117
        return "enum %TEST_CLASS_NAME% implements Cloneable, @RTB @RTB Runnable { TEST; public void run() { } }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   118
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   119
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   120
    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   121
            genericLocation  = { 3, 0 })
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   122
    public String regularEnumExtendsParametrized() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   123
        return
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   124
            "enum %TEST_CLASS_NAME% implements Cloneable, Comparator<@TB String> { TEST;  "
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   125
            + "public int compare(String a, String b) { return 0; }}";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   126
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   127
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   128
    @TADescription(annotation = "RTBs", type = CLASS_EXTENDS, typeIndex = 1,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   129
            genericLocation  = { 3, 0 })
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   130
    public String regularEnumExtendsParametrizedRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   131
        return
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   132
                "enum %TEST_CLASS_NAME% implements Cloneable, Comparator<@RTB @RTB String> { TEST;  "
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   133
                        + "public int compare(String a, String b) { return 0; }}";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 22448
diff changeset
   134
    }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   135
}