langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
author jjg
Sun, 20 Oct 2013 12:46:12 -0700
changeset 21481 f0aeb1da97bd
parent 19651 b1aa46cc2198
child 24896 986d876a9121
permissions -rw-r--r--
8026791: wrong type_path encoded for method_return on an inner class constructor Reviewed-by: jjg Contributed-by: wdietl@gmail.com
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
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    26
 * @bug 8026791
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
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    36
    @TADescriptions({
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    37
        @TADescription(annotation = "TA", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    38
        @TADescription(annotation = "TB", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    39
        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    40
    })
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    41
    public String regularClass() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    42
        return "class Test { @TA Test() {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    43
                           " @TB Test(@TC int b) {} }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    44
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    45
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    46
    @TADescriptions({
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    47
        @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0}),
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    48
        @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    49
        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    50
    })
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    51
    @TestClass("Test$Inner")
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    52
    public String innerClass() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    53
        return "class Test { class Inner {" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    54
               " @TA Inner() {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    55
               " @TB Inner(@TC int b) {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    56
               " } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    57
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    58
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    59
    @TADescriptions({
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    60
        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    61
        @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0}),
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    62
        @TADescription(annotation = "TC", type = METHOD_RECEIVER),
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    63
        @TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}),
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    64
        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
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
    @TestClass("Test$Inner")
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    67
    public String innerClass2() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    68
        return "class Test { class Inner {" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    69
               " @TB Inner(@TA Test Test.this) {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    70
               " @TD Inner(@TC Test Test.this, @TE int b) {}" +
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
    }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    73
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    74
    @TADescriptions({
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    75
        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    76
        @TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    77
        @TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    78
        @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
21481
f0aeb1da97bd 8026791: wrong type_path encoded for method_return on an inner class constructor
jjg
parents: 19651
diff changeset
    79
        @TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0}),
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    80
        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    81
    })
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    82
    @TestClass("Outer$Middle$Inner")
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    83
    public String innerClass3() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    84
        return "class Outer { class Middle { class Inner {" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    85
               " @TC Inner(@TA Outer. @TB Middle Middle.this) {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    86
               " @TE Inner(@TD Middle Outer.Middle.this, @TF int b) {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    87
               " } } }";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    88
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    89
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    90
    @TADescriptions({
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    91
        @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    92
                typeIndex = 0, offset = 4),
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    93
        @TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    94
                typeIndex = 0, offset = 0)
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    95
    })
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    96
    public String generic1() {
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    97
        return "class Test { <T> Test(int i) { new <@TA T>Test(); }" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    98
                           " <T> Test() { <@TB String>this(0); } }";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    99
    }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   100
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   101
    @TADescriptions({
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   102
        @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   103
                typeIndex = 0, offset = 0)
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   104
    })
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   105
    public String generic2() {
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   106
        return "class Super { <T> Super(int i) { } } " +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   107
                "class Test extends Super { <T> Test() { <@TA String>super(0); } }";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   108
    }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   109
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   110
}