langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java
author mchung
Wed, 27 May 2015 13:25:18 -0700
changeset 30846 2b3f379840f0
parent 30730 d3ce7619db2c
permissions -rw-r--r--
8074432: Move jdeps and javap to jdk.jdeps module Reviewed-by: jjg, alanb, erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24896
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     4
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     8
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    13
 * accompanied this code).
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    14
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    18
 *
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    21
 * questions.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    22
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    23
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    24
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    25
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    26
/*
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    27
 * @test
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    28
 * @bug 8013852 8042451
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    29
 * @summary Test population of reference info for instance and class initializers
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    30
 * @author Werner Dietl
30846
2b3f379840f0 8074432: Move jdeps and javap to jdk.jdeps module
mchung
parents: 30730
diff changeset
    31
 * @modules jdk.jdeps/com.sun.tools.classfile
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    32
 * @compile -g Driver.java ReferenceInfoUtil.java Initializers.java
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    33
 * @run main Driver Initializers
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    34
 */
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    35
public class Initializers {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    36
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    37
    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    38
    @TADescription(annotation = "TB", type = NEW,
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    39
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    40
        public String instanceInit1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    41
        return "class %TEST_CLASS_NAME% { { Object o = new @TA ArrayList<@TB String>(); } }";
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    42
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    43
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    44
    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    45
    @TADescription(annotation = "TB", type = NEW,
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    46
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    47
    @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    48
    @TADescription(annotation = "TD", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    49
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    50
        public String instanceInit2() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    51
        return "class %TEST_CLASS_NAME% { Object f = new @TA ArrayList<@TB String>(); " +
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    52
                " { Object o = new @TC ArrayList<@TD String>(); } }";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    53
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    54
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    55
    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    56
    @TADescription(annotation = "TB", type = NEW,
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    57
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    58
        public String staticInit1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    59
        return "class %TEST_CLASS_NAME% { static { Object o = new @TA ArrayList<@TB String>(); } }";
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    60
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    61
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    62
    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    63
    @TADescription(annotation = "TB", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    64
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    65
    @TADescription(annotation = "TC", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    66
    @TADescription(annotation = "TD", type = NEW,
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    67
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    68
    @TADescription(annotation = "TE", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    69
    @TADescription(annotation = "TF", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    70
                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    71
        public String staticInit2() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    72
        return "class %TEST_CLASS_NAME% { Object f = new @TA ArrayList<@TB String>(); " +
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    73
                " static Object g = new @TC ArrayList<@TD String>(); " +
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    74
                " static { Object o = new @TE ArrayList<@TF String>(); } }";
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    75
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
    76
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    77
    @TADescription(annotation = "TA", type = CAST,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    78
                typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    79
        public String lazyConstantCast1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    80
        return "class %TEST_CLASS_NAME% { public static final Object o = (@TA Object) null; }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    81
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    82
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    83
    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    84
    @TADescription(annotation = "RTBs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    85
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    86
    public String instanceInitRepeatableAnnotation1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    87
        return "class %TEST_CLASS_NAME% { { Object o = new @RTA @RTA ArrayList<@RTB @RTB String>(); } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    88
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    89
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    90
    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    91
    @TADescription(annotation = "RTBs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    92
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    93
    @TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    94
    @TADescription(annotation = "RTDs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    95
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    96
    public String instanceInitRepeatableAnnotation2() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    97
        return "class %TEST_CLASS_NAME% { Object f = new @RTA @RTA ArrayList<@RTB @RTB String>(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    98
                " { Object o = new @RTC @RTC ArrayList<@RTD @RTD String>(); } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
    99
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   100
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   101
    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   102
    @TADescription(annotation = "RTBs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   103
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   104
    public String staticInitRepeatableAnnotation1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   105
        return "class %TEST_CLASS_NAME% { static { Object o = new @RTA @RTA ArrayList<@RTB @RTB String>(); } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   106
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   107
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   108
    @TADescription(annotation = "RTAs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   109
    @TADescription(annotation = "RTBs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   110
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   111
    @TADescription(annotation = "RTCs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   112
    @TADescription(annotation = "RTDs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   113
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   114
    @TADescription(annotation = "RTEs", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   115
    @TADescription(annotation = "RTFs", type = NEW,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   116
            genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   117
    public String staticInitRepeatableAnnotation2() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   118
        return "class %TEST_CLASS_NAME% { Object f = new @RTA @RTA ArrayList<@RTB @RTB String>(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   119
                " static Object g = new @RTC @RTC ArrayList<@RTD @RTD String>(); " +
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   120
                " static { Object o = new @RTE @RTE ArrayList<@RTF @RTF String>(); } }";
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   121
    }
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   122
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   123
    // TODO: test interaction with several constructors, especially non-initial constructors.
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   124
    // I don't think this kind of test is possible here.
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   125
24896
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   126
    @TADescription(annotation = "RTAs", type = CAST,
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   127
            typeIndex = 0, offset = ReferenceInfoUtil.IGNORE_VALUE)
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   128
    public String lazyConstantCastRepeatableAnnotation1() {
986d876a9121 8042451: Write tests for all possible kinds of type annotation
aeremeev
parents: 24292
diff changeset
   129
        return "class %TEST_CLASS_NAME% { public static final Object o = (@RTA @RTA Object) null; }";
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   130
    }
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents:
diff changeset
   131
}