Wed, 15 Oct 2008 17:23:55 +0100
6759682: APT: compiler message file broken after refactoring of com.sun.tools.javac.util.Message
Summary: JavacMessages should refresh its own bundle cache when a new resource bundle is added by APT
Reviewed-by: jjg
1 /*
2 * Copyright 2004-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
25 /*
26 * @test
27 * @bug 4853450 5055963
28 * @summary InterfaceType tests
29 * @library ../../lib
30 * @run main/othervm InterfaceTyp
31 */
34 import java.util.*;
35 import com.sun.mirror.declaration.*;
36 import com.sun.mirror.type.*;
37 import com.sun.mirror.util.*;
40 public class InterfaceTyp<T1,T2> extends Tester {
42 public static void main(String[] args) {
43 (new InterfaceTyp()).run();
44 }
47 // Declarations used by tests
49 interface I1<S> extends Set<String> {
50 interface I2<R> {
51 }
52 }
55 // Generate some interface types to test
56 private I1<T1> f0;
57 private I1<String> f1;
58 private I1 f2;
59 private I1.I2<String> f3;
60 private I1.I2 f4;
61 private I1<T1> f5;
62 private I3<T1> f6;
63 private static final int NUMTYPES = 7;
65 // Type mirrors corresponding to the types of the above fields
66 private InterfaceType[] t = new InterfaceType[NUMTYPES];
68 protected void init() {
69 for (int i = 0; i < t.length; i++) {
70 t[i] = (InterfaceType) getField("f"+i).getType();
71 }
72 }
75 // TypeMirror methods
77 @Test(result="interface")
78 Collection<String> accept() {
79 final Collection<String> res = new ArrayList<String>();
81 t[0].accept(new SimpleTypeVisitor() {
82 public void visitReferenceType(ReferenceType t) {
83 res.add("ref type");
84 }
85 public void visitClassType(ClassType t) {
86 res.add("class");
87 }
88 public void visitInterfaceType(InterfaceType t) {
89 res.add("interface");
90 }
91 });
92 return res;
93 }
95 @Test(result="true")
96 boolean equals1() {
97 return t[0].equals(t[0]);
98 }
100 @Test(result="false")
101 boolean equals2() {
102 return t[0].equals(t[1]);
103 }
105 // Raw type is not same as type instantiated with unbounded type var.
106 @Test(result="false")
107 boolean equals3() {
108 return t[0].equals(t[2]);
109 }
111 // I1<T1> is same type as I1<T1>
112 @Test(result="true")
113 boolean equals4() {
114 return t[0].equals(t[5]);
115 }
117 @Test(result={
118 "InterfaceTyp.I1<T1>",
119 "InterfaceTyp.I1<java.lang.String>",
120 "InterfaceTyp.I1",
121 "InterfaceTyp.I1.I2<java.lang.String>",
122 "InterfaceTyp.I1.I2",
123 "InterfaceTyp.I1<T1>",
124 "I3<T1>"
125 },
126 ordered=true)
127 Collection<String> toStringTests() {
128 Collection<String> res = new ArrayList<String>();
129 for (InterfaceType i : t) {
130 res.add(i.toString());
131 }
132 return res;
133 }
136 // DeclaredType methods
138 @Test(result={"T1"})
139 Collection<TypeMirror> getActualTypeArguments1() {
140 return t[0].getActualTypeArguments();
141 }
143 @Test(result={})
144 Collection<TypeMirror> getActualTypeArguments2() {
145 return t[2].getActualTypeArguments();
146 }
148 @Test(result={"java.lang.String"})
149 Collection<TypeMirror> getActualTypeArguments3() {
150 return t[3].getActualTypeArguments();
151 }
153 @Test(result="InterfaceTyp")
154 DeclaredType getContainingType1() {
155 return t[0].getContainingType();
156 }
158 @Test(result="InterfaceTyp.I1")
159 DeclaredType getContainingType2() {
160 return t[3].getContainingType();
161 }
163 @Test(result="null")
164 DeclaredType getContainingTypeTopLevel() {
165 return t[6].getContainingType();
166 }
168 @Test(result={"java.util.Set<java.lang.String>"})
169 Collection<InterfaceType> getSuperinterfaces() {
170 return t[0].getSuperinterfaces();
171 }
175 // InterfaceType method
177 @Test(result="InterfaceTyp.I1<S>")
178 InterfaceDeclaration getDeclaration1() {
179 return t[0].getDeclaration();
180 }
182 @Test(result="InterfaceTyp.I1.I2<R>")
183 InterfaceDeclaration getDeclaration2a() {
184 return t[3].getDeclaration();
185 }
187 @Test(result="InterfaceTyp.I1.I2<R>")
188 InterfaceDeclaration getDeclaration2b() {
189 return t[4].getDeclaration();
190 }
192 @Test(result="true")
193 boolean getDeclarationCaching() {
194 return t[0].getDeclaration() == t[5].getDeclaration();
195 }
196 }
199 // A top-level interface used by tests.
201 interface I3<T> {
202 }