Sat, 13 Apr 2013 12:25:44 +0100
8010659: Javac Crashes while building OpenJFX
Reviewed-by: jjg
Contributed-by: maurizio.cimadamore@oracle.com
1 /*
2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
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 */
24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
26 /*
27 * @test
28 * @summary Test population of reference info for method return
29 * @compile -g Driver.java ReferenceInfoUtil.java MethodReturns.java
30 * @run main Driver MethodReturns
31 */
32 public class MethodReturns {
34 // Method returns
35 @TADescription(annotation = "TA", type = METHOD_RETURN)
36 public String methodReturnAsPrimitive() {
37 return "@TA int test() { return 0; }";
38 }
40 @TADescription(annotation = "TA", type = METHOD_RETURN)
41 public String methodReturnAsObject() {
42 return "@TA Object test() { return null; }";
43 }
45 @TADescriptions({
46 @TADescription(annotation = "TA", type = METHOD_RETURN),
47 @TADescription(annotation = "TB", type = METHOD_RETURN,
48 genericLocation = { 3, 0 }),
49 @TADescription(annotation = "TC", type = METHOD_RETURN,
50 genericLocation = { 3, 1 }),
51 @TADescription(annotation = "TD", type = METHOD_RETURN,
52 genericLocation = { 3, 1, 3, 0 })
53 })
54 public String methodReturnAsParametrized() {
55 return "@TA Map<@TB String, @TC List<@TD String>> test() { return null; }";
56 }
58 @TADescriptions({
59 @TADescription(annotation = "TA", type = METHOD_RETURN),
60 @TADescription(annotation = "TB", type = METHOD_RETURN,
61 genericLocation = { 0, 0 }),
62 @TADescription(annotation = "TC", type = METHOD_RETURN,
63 genericLocation = { 0, 0, 0, 0 })
64 })
65 public String methodReturnAsArray() {
66 return "@TC String @TA [] @TB [] test() { return null; }";
67 }
69 @TADescriptions({
70 @TADescription(annotation = "TA", type = METHOD_RETURN),
71 @TADescription(annotation = "TB", type = METHOD_RETURN,
72 genericLocation = { 0, 0 }),
73 @TADescription(annotation = "TC", type = METHOD_RETURN,
74 genericLocation = { 0, 0, 0, 0 })
75 })
76 public String methodReturnAsArrayOld() {
77 return "@TC String test() @TA [] @TB [] { return null; }";
78 }
80 @TADescriptions({})
81 public String methodWithDeclarationAnnotation() {
82 return "@Decl String test() { return null; }";
83 }
85 @TADescriptions({})
86 public String methodWithNoTargetAnno() {
87 return "@A String test() { return null; }";
88 }
90 // Smoke tests
91 @TADescription(annotation = "TA", type = METHOD_RETURN)
92 public String interfaceMethodReturnAsObject() {
93 return "interface Test { @TA Object test(); }";
94 }
96 @TADescription(annotation = "TA", type = METHOD_RETURN)
97 public String abstractMethodReturnAsObject() {
98 return "abstract class Test { abstract @TA Object test(); }";
99 }
102 @TADescriptions({
103 @TADescription(annotation = "TA", type = METHOD_RETURN),
104 @TADescription(annotation = "TB", type = METHOD_RETURN,
105 genericLocation = { 3, 0 }),
106 @TADescription(annotation = "TC", type = METHOD_RETURN,
107 genericLocation = { 3, 1 }),
108 @TADescription(annotation = "TD", type = METHOD_RETURN,
109 genericLocation = { 3, 1, 3, 0 })
110 })
111 public String interfaceMethodReturnAsParametrized() {
112 return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test(); }";
113 }
115 @TADescriptions({
116 @TADescription(annotation = "TA", type = METHOD_RETURN,
117 genericLocation = { 3, 0 }),
118 @TADescription(annotation = "TB", type = METHOD_RETURN,
119 genericLocation = { 3, 0, 2, 0 }),
120 @TADescription(annotation = "TC", type = METHOD_RETURN,
121 genericLocation = { 3, 0, 2, 0, 1, 0 }),
122 @TADescription(annotation = "TD", type = METHOD_RETURN,
123 genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 }),
124 @TADescription(annotation = "TE", type = METHOD_RETURN,
125 genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 }),
126 @TADescription(annotation = "TF", type = METHOD_RETURN,
127 genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1, 2, 0 })
128 })
129 public String methodReturnAsNestedWildcard() {
130 return "Set<@TA ? extends @TB GOuter<String, String>. @TC GInner<@TD String, @TE ? super @TF Object>> entrySet() { return null; }";
131 }
133 @TADescriptions({
134 @TADescription(annotation = "TA", type = METHOD_RETURN,
135 genericLocation = { 3, 0, 1, 0, 3, 0 }),
136 @TADescription(annotation = "TB", type = METHOD_RETURN,
137 genericLocation = { 3, 0, 1, 0, 3, 1 }),
138 @TADescription(annotation = "TC", type = METHOD_RETURN,
139 genericLocation = { 3, 0, 1, 0, 3, 1, 2, 0 })
140 })
141 public String methodReturnAsNestedWildcard2() {
142 return "class GOuter<X, Y> { class GInner<X, Y> {} } " +
143 "class Test<K> { Set<GOuter<String, String>.GInner<@TA K, @TB ? extends @TC Object>> entrySet() { return null; } }";
144 }
146 @TADescriptions({
147 @TADescription(annotation = "TB", type = METHOD_RETURN,
148 genericLocation = { 3, 0, 2, 0 }),
149 @TADescription(annotation = "TC", type = METHOD_RETURN,
150 genericLocation = { 3, 0, 2, 0, 1, 0 }),
151 })
152 public String methodReturnAsNestedWildcard3() {
153 return "Set<? extends @TB GOuter<String, String>. @TC GInner<String, Object>> entrySet() { return null; }";
154 }
156 @TADescriptions({
157 @TADescription(annotation = "TC", type = METHOD_RETURN,
158 genericLocation = { 3, 0, 2, 0, 1, 0 }),
159 })
160 public String methodReturnAsNestedWildcard4() {
161 return "Set<? extends GOuter<String, String>. @TC GInner<String, Object>> entrySet() { return null; }";
162 }
164 @TADescriptions({
165 @TADescription(annotation = "TB", type = METHOD_RETURN,
166 genericLocation = { 3, 0, 2, 0 }),
167 @TADescription(annotation = "TC", type = METHOD_RETURN,
168 genericLocation = { 3, 0, 2, 0, 1, 0 }),
169 })
170 public String methodReturnAsNestedWildcard5() {
171 return "Set<? extends @TB Outer. @TC Inner> entrySet() { return null; }";
172 }
174 @TADescriptions({
175 @TADescription(annotation = "TA", type = METHOD_RETURN,
176 genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 }),
177 @TADescription(annotation = "TB", type = METHOD_RETURN,
178 genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 }),
179 @TADescription(annotation = "TC", type = METHOD_RETURN,
180 genericLocation = { 3, 0, 2, 0, 1, 0 }),
181 })
182 public String methodReturnAsNestedWildcard6() {
183 return "Set<? extends GOuter<String, String>. @TC GInner<@TA String, @TB Object>> entrySet() { return null; }";
184 }
186 }