langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
author emc
Fri, 13 Feb 2015 17:00:45 -0500
changeset 29050 76df9080086c
parent 27545 9b19c6e31489
child 30730 d3ce7619db2c
permissions -rw-r--r--
8066725: javac produces classfiles it cannot read Summary: Revert behavioral changes from 8029012 and 8065132 Reviewed-by: jfranck
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
     1
/*
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
     2
 * Copyright (c) 2012, 2013, 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
/*
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    25
 * @test
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    26
 * @bug 8026791 8042451
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    27
 * @summary Test population of reference info for constructor results
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    28
 * @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    29
 * @run main Driver Constructors
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    30
 */
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    31
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    32
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    33
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    34
public class Constructors {
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: 21481
diff changeset
    36
    @TADescription(annotation = "TA", type = METHOD_RETURN)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    37
    @TADescription(annotation = "TB", type = METHOD_RETURN)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    38
    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    39
    public String regularClass() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    40
        return "class %TEST_CLASS_NAME% { @TA %TEST_CLASS_NAME%() {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    41
                           " @TB %TEST_CLASS_NAME%(@TC int b) {} }";
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    42
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    43
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    44
    @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    45
    @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
29050
76df9080086c 8066725: javac produces classfiles it cannot read
emc
parents: 27545
diff changeset
    46
    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    47
    @TestClass("%TEST_CLASS_NAME%$Inner")
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    48
    public String innerClass() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    49
        return "class %TEST_CLASS_NAME% { class Inner {" +
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    50
               " @TA Inner() {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    51
               " @TB Inner(@TC int b) {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    52
               " } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    53
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    54
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    55
    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    56
    @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    57
    @TADescription(annotation = "TC", type = METHOD_RECEIVER)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    58
    @TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0})
29050
76df9080086c 8066725: javac produces classfiles it cannot read
emc
parents: 27545
diff changeset
    59
    @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    60
    @TestClass("%TEST_CLASS_NAME%$Inner")
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    61
    public String innerClass2() {
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    62
        return "class %TEST_CLASS_NAME% { class Inner {" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    63
               " @TB Inner(@TA %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this) {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    64
               " @TD Inner(@TC %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this, @TE int b) {}" +
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    65
               " } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    66
    }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    67
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    68
    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    69
    @TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    70
    @TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    71
    @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    72
    @TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
29050
76df9080086c 8066725: javac produces classfiles it cannot read
emc
parents: 27545
diff changeset
    73
    @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    74
    @TestClass("Outer$Middle$Inner")
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    75
    public String innerClass3() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    76
        return "class Outer { class Middle { class Inner {" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    77
               " @TC Inner(@TA Outer. @TB Middle Middle.this) {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    78
               " @TE Inner(@TD Middle Outer.Middle.this, @TF int b) {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    79
               " } } }";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    80
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    81
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    82
    @TADescription(annotation = "RTAs", type = METHOD_RETURN)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    83
    @TADescription(annotation = "RTBs", type = METHOD_RETURN)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    84
    @TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    85
    public String regularClassRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    86
        return "class %TEST_CLASS_NAME% { @RTA  @RTA %TEST_CLASS_NAME%() {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    87
                " @RTB @RTB %TEST_CLASS_NAME%(@RTC @RTC int b) {} }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    88
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    89
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    90
    @TADescription(annotation = "RTAs", type = METHOD_RETURN, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    91
    @TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
29050
76df9080086c 8066725: javac produces classfiles it cannot read
emc
parents: 27545
diff changeset
    92
    @TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    93
    @TestClass("%TEST_CLASS_NAME%$Inner")
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    94
    public String innerClassRepeatableAnnotation() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    95
        return "class %TEST_CLASS_NAME% { class Inner {" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    96
                " @RTA @RTA Inner() {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    97
                " @RTB @RTB Inner(@RTC @RTC int b) {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
    98
                " } }";
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    99
    }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   100
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   101
    @TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   102
    @TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   103
    @TADescription(annotation = "RTCs", type = METHOD_RECEIVER)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   104
    @TADescription(annotation = "RTDs", type = METHOD_RETURN, genericLocation = {1, 0})
29050
76df9080086c 8066725: javac produces classfiles it cannot read
emc
parents: 27545
diff changeset
   105
    @TADescription(annotation = "RTEs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   106
    @TestClass("%TEST_CLASS_NAME%$Inner")
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   107
    public String innerClassRepeatableAnnotation2() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   108
        return "class %TEST_CLASS_NAME% { class Inner {" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   109
                " @RTB @RTB Inner(@RTA @RTA %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this) {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   110
                " @RTD @RTD Inner(@RTC @RTC %TEST_CLASS_NAME% %TEST_CLASS_NAME%.this, @RTE @RTE int b) {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   111
                " } }";
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   112
    }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   113
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   114
    @TADescription(annotation = "RTAs", type = METHOD_RECEIVER)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   115
    @TADescription(annotation = "RTBs", type = METHOD_RECEIVER, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   116
    @TADescription(annotation = "RTCs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   117
    @TADescription(annotation = "RTDs", type = METHOD_RECEIVER, genericLocation = {1, 0})
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   118
    @TADescription(annotation = "RTEs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
29050
76df9080086c 8066725: javac produces classfiles it cannot read
emc
parents: 27545
diff changeset
   119
    @TADescription(annotation = "RTFs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   120
    @TestClass("Outer$Middle$Inner")
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   121
    public String innerClassRepatableAnnotation3() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   122
        return "class Outer { class Middle { class Inner {" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   123
                " @RTC @RTC Inner(@RTA @RTA Outer. @RTB @RTB Middle Middle.this) {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   124
                " @RTE @RTE Inner(@RTD @RTD Middle Outer.Middle.this, @RTF @RTF int b) {}" +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   125
                " } } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 21481
diff changeset
   126
    }
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   127
}