author | mchung |
Wed, 27 May 2015 13:25:18 -0700 | |
changeset 30846 | 2b3f379840f0 |
parent 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
17578 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
import static com.sun.tools.classfile.TypeAnnotation.TargetType.*; |
|
25 |
||
26 |
/* |
|
27 |
* @test |
|
24896
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
24292
diff
changeset
|
28 |
* @bug 8013852 8042451 |
17578 | 29 |
* @summary Test population of reference info for instance and class initializers |
30 |
* @author Werner Dietl |
|
30846 | 31 |
* @modules jdk.jdeps/com.sun.tools.classfile |
17578 | 32 |
* @compile -g Driver.java ReferenceInfoUtil.java Initializers.java |
33 |
* @run main Driver Initializers |
|
34 |
*/ |
|
35 |
public class Initializers { |
|
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 | 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 | 42 |
} |
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 | 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 | 52 |
" { Object o = new @TC ArrayList<@TD String>(); } }"; |
53 |
} |
|
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 | 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 | 60 |
} |
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 | 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 | 73 |
" static Object g = new @TC ArrayList<@TD String>(); " + |
74 |
" static { Object o = new @TE ArrayList<@TF String>(); } }"; |
|
75 |
} |
|
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 | 124 |
// I don't think this kind of test is possible here. |
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 | 130 |
} |
131 |
} |