langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
author jjg
Wed, 21 Aug 2013 16:13:50 -0700
changeset 19651 b1aa46cc2198
parent 17578 46ac954e4a84
child 21481 f0aeb1da97bd
permissions -rw-r--r--
8023515: import type-annotations updates 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
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
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    28
 * @summary Test population of reference info for constructor results
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    29
 * @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    30
 * @run main Driver Constructors
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    31
 */
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    32
public class Constructors {
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
    @TADescriptions({
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    35
        @TADescription(annotation = "TA", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    36
        @TADescription(annotation = "TB", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    37
        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    38
    })
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    39
    public String regularClass() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    40
        return "class Test { @TA Test() {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    41
                           " @TB Test(@TC int b) {} }";
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
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    44
    @TADescriptions({
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    45
        @TADescription(annotation = "TA", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    46
        @TADescription(annotation = "TB", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    47
        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
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
    @TestClass("Test$Inner")
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    50
    public String innerClass() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    51
        return "class Test { class Inner {" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    52
               " @TA Inner() {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    53
               " @TB Inner(@TC int b) {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    54
               " } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    55
    }
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
    @TADescriptions({
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    58
        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    59
        @TADescription(annotation = "TB", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    60
        @TADescription(annotation = "TC", type = METHOD_RECEIVER),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    61
        @TADescription(annotation = "TD", type = METHOD_RETURN),
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    62
        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    63
    })
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    64
    @TestClass("Test$Inner")
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    65
    public String innerClass2() {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    66
        return "class Test { class Inner {" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    67
               " @TB Inner(@TA Test Test.this) {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    68
               " @TD Inner(@TC Test Test.this, @TE int b) {}" +
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    69
               " } }";
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
    70
    }
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    71
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    72
    @TADescriptions({
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    73
        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    74
        @TADescription(annotation = "TB", type = METHOD_RECEIVER, genericLocation = {1, 0}),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    75
        @TADescription(annotation = "TC", type = METHOD_RETURN),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    76
        @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    77
        @TADescription(annotation = "TE", type = METHOD_RETURN),
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    78
        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
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
    @TestClass("Outer$Middle$Inner")
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    81
    public String innerClass3() {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    82
        return "class Outer { class Middle { class Inner {" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    83
               " @TC Inner(@TA Outer. @TB Middle Middle.this) {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    84
               " @TE Inner(@TD Middle Outer.Middle.this, @TF int b) {}" +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    85
               " } } }";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    86
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15557
diff changeset
    87
19651
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    88
    @TADescriptions({
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    89
        @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    90
                typeIndex = 0, offset = 4),
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    91
        @TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    92
                typeIndex = 0, offset = 0)
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    93
    })
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    94
    public String generic1() {
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    95
        return "class Test { <T> Test(int i) { new <@TA T>Test(); }" +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    96
                           " <T> Test() { <@TB String>this(0); } }";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    97
    }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    98
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
    99
    @TADescriptions({
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   100
        @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   101
                typeIndex = 0, offset = 0)
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   102
    })
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   103
    public String generic2() {
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   104
        return "class Super { <T> Super(int i) { } } " +
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   105
                "class Test extends Super { <T> Test() { <@TA String>super(0); } }";
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   106
    }
b1aa46cc2198 8023515: import type-annotations updates
jjg
parents: 17578
diff changeset
   107
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents:
diff changeset
   108
}