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
duke@1 | 1 | /* |
duke@1 | 2 | * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. |
duke@1 | 8 | * |
duke@1 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | * accompanied this code). |
duke@1 | 14 | * |
duke@1 | 15 | * You should have received a copy of the GNU General Public License version |
duke@1 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | * |
duke@1 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 21 | * have any questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | |
duke@1 | 25 | /* |
duke@1 | 26 | * @test |
duke@1 | 27 | * @bug 4853450 5055963 |
duke@1 | 28 | * @summary InterfaceType tests |
duke@1 | 29 | * @library ../../lib |
jjg@132 | 30 | * @run main/othervm InterfaceTyp |
duke@1 | 31 | */ |
duke@1 | 32 | |
duke@1 | 33 | |
duke@1 | 34 | import java.util.*; |
duke@1 | 35 | import com.sun.mirror.declaration.*; |
duke@1 | 36 | import com.sun.mirror.type.*; |
duke@1 | 37 | import com.sun.mirror.util.*; |
duke@1 | 38 | |
duke@1 | 39 | |
duke@1 | 40 | public class InterfaceTyp<T1,T2> extends Tester { |
duke@1 | 41 | |
duke@1 | 42 | public static void main(String[] args) { |
duke@1 | 43 | (new InterfaceTyp()).run(); |
duke@1 | 44 | } |
duke@1 | 45 | |
duke@1 | 46 | |
duke@1 | 47 | // Declarations used by tests |
duke@1 | 48 | |
duke@1 | 49 | interface I1<S> extends Set<String> { |
duke@1 | 50 | interface I2<R> { |
duke@1 | 51 | } |
duke@1 | 52 | } |
duke@1 | 53 | |
duke@1 | 54 | |
duke@1 | 55 | // Generate some interface types to test |
duke@1 | 56 | private I1<T1> f0; |
duke@1 | 57 | private I1<String> f1; |
duke@1 | 58 | private I1 f2; |
duke@1 | 59 | private I1.I2<String> f3; |
duke@1 | 60 | private I1.I2 f4; |
duke@1 | 61 | private I1<T1> f5; |
duke@1 | 62 | private I3<T1> f6; |
duke@1 | 63 | private static final int NUMTYPES = 7; |
duke@1 | 64 | |
duke@1 | 65 | // Type mirrors corresponding to the types of the above fields |
duke@1 | 66 | private InterfaceType[] t = new InterfaceType[NUMTYPES]; |
duke@1 | 67 | |
duke@1 | 68 | protected void init() { |
duke@1 | 69 | for (int i = 0; i < t.length; i++) { |
duke@1 | 70 | t[i] = (InterfaceType) getField("f"+i).getType(); |
duke@1 | 71 | } |
duke@1 | 72 | } |
duke@1 | 73 | |
duke@1 | 74 | |
duke@1 | 75 | // TypeMirror methods |
duke@1 | 76 | |
duke@1 | 77 | @Test(result="interface") |
duke@1 | 78 | Collection<String> accept() { |
duke@1 | 79 | final Collection<String> res = new ArrayList<String>(); |
duke@1 | 80 | |
duke@1 | 81 | t[0].accept(new SimpleTypeVisitor() { |
duke@1 | 82 | public void visitReferenceType(ReferenceType t) { |
duke@1 | 83 | res.add("ref type"); |
duke@1 | 84 | } |
duke@1 | 85 | public void visitClassType(ClassType t) { |
duke@1 | 86 | res.add("class"); |
duke@1 | 87 | } |
duke@1 | 88 | public void visitInterfaceType(InterfaceType t) { |
duke@1 | 89 | res.add("interface"); |
duke@1 | 90 | } |
duke@1 | 91 | }); |
duke@1 | 92 | return res; |
duke@1 | 93 | } |
duke@1 | 94 | |
duke@1 | 95 | @Test(result="true") |
duke@1 | 96 | boolean equals1() { |
duke@1 | 97 | return t[0].equals(t[0]); |
duke@1 | 98 | } |
duke@1 | 99 | |
duke@1 | 100 | @Test(result="false") |
duke@1 | 101 | boolean equals2() { |
duke@1 | 102 | return t[0].equals(t[1]); |
duke@1 | 103 | } |
duke@1 | 104 | |
duke@1 | 105 | // Raw type is not same as type instantiated with unbounded type var. |
duke@1 | 106 | @Test(result="false") |
duke@1 | 107 | boolean equals3() { |
duke@1 | 108 | return t[0].equals(t[2]); |
duke@1 | 109 | } |
duke@1 | 110 | |
duke@1 | 111 | // I1<T1> is same type as I1<T1> |
duke@1 | 112 | @Test(result="true") |
duke@1 | 113 | boolean equals4() { |
duke@1 | 114 | return t[0].equals(t[5]); |
duke@1 | 115 | } |
duke@1 | 116 | |
duke@1 | 117 | @Test(result={ |
duke@1 | 118 | "InterfaceTyp.I1<T1>", |
duke@1 | 119 | "InterfaceTyp.I1<java.lang.String>", |
duke@1 | 120 | "InterfaceTyp.I1", |
duke@1 | 121 | "InterfaceTyp.I1.I2<java.lang.String>", |
duke@1 | 122 | "InterfaceTyp.I1.I2", |
duke@1 | 123 | "InterfaceTyp.I1<T1>", |
duke@1 | 124 | "I3<T1>" |
duke@1 | 125 | }, |
duke@1 | 126 | ordered=true) |
duke@1 | 127 | Collection<String> toStringTests() { |
duke@1 | 128 | Collection<String> res = new ArrayList<String>(); |
duke@1 | 129 | for (InterfaceType i : t) { |
duke@1 | 130 | res.add(i.toString()); |
duke@1 | 131 | } |
duke@1 | 132 | return res; |
duke@1 | 133 | } |
duke@1 | 134 | |
duke@1 | 135 | |
duke@1 | 136 | // DeclaredType methods |
duke@1 | 137 | |
duke@1 | 138 | @Test(result={"T1"}) |
duke@1 | 139 | Collection<TypeMirror> getActualTypeArguments1() { |
duke@1 | 140 | return t[0].getActualTypeArguments(); |
duke@1 | 141 | } |
duke@1 | 142 | |
duke@1 | 143 | @Test(result={}) |
duke@1 | 144 | Collection<TypeMirror> getActualTypeArguments2() { |
duke@1 | 145 | return t[2].getActualTypeArguments(); |
duke@1 | 146 | } |
duke@1 | 147 | |
duke@1 | 148 | @Test(result={"java.lang.String"}) |
duke@1 | 149 | Collection<TypeMirror> getActualTypeArguments3() { |
duke@1 | 150 | return t[3].getActualTypeArguments(); |
duke@1 | 151 | } |
duke@1 | 152 | |
duke@1 | 153 | @Test(result="InterfaceTyp") |
duke@1 | 154 | DeclaredType getContainingType1() { |
duke@1 | 155 | return t[0].getContainingType(); |
duke@1 | 156 | } |
duke@1 | 157 | |
duke@1 | 158 | @Test(result="InterfaceTyp.I1") |
duke@1 | 159 | DeclaredType getContainingType2() { |
duke@1 | 160 | return t[3].getContainingType(); |
duke@1 | 161 | } |
duke@1 | 162 | |
duke@1 | 163 | @Test(result="null") |
duke@1 | 164 | DeclaredType getContainingTypeTopLevel() { |
duke@1 | 165 | return t[6].getContainingType(); |
duke@1 | 166 | } |
duke@1 | 167 | |
duke@1 | 168 | @Test(result={"java.util.Set<java.lang.String>"}) |
duke@1 | 169 | Collection<InterfaceType> getSuperinterfaces() { |
duke@1 | 170 | return t[0].getSuperinterfaces(); |
duke@1 | 171 | } |
duke@1 | 172 | |
duke@1 | 173 | |
duke@1 | 174 | |
duke@1 | 175 | // InterfaceType method |
duke@1 | 176 | |
duke@1 | 177 | @Test(result="InterfaceTyp.I1<S>") |
duke@1 | 178 | InterfaceDeclaration getDeclaration1() { |
duke@1 | 179 | return t[0].getDeclaration(); |
duke@1 | 180 | } |
duke@1 | 181 | |
duke@1 | 182 | @Test(result="InterfaceTyp.I1.I2<R>") |
duke@1 | 183 | InterfaceDeclaration getDeclaration2a() { |
duke@1 | 184 | return t[3].getDeclaration(); |
duke@1 | 185 | } |
duke@1 | 186 | |
duke@1 | 187 | @Test(result="InterfaceTyp.I1.I2<R>") |
duke@1 | 188 | InterfaceDeclaration getDeclaration2b() { |
duke@1 | 189 | return t[4].getDeclaration(); |
duke@1 | 190 | } |
duke@1 | 191 | |
duke@1 | 192 | @Test(result="true") |
duke@1 | 193 | boolean getDeclarationCaching() { |
duke@1 | 194 | return t[0].getDeclaration() == t[5].getDeclaration(); |
duke@1 | 195 | } |
duke@1 | 196 | } |
duke@1 | 197 | |
duke@1 | 198 | |
duke@1 | 199 | // A top-level interface used by tests. |
duke@1 | 200 | |
duke@1 | 201 | interface I3<T> { |
duke@1 | 202 | } |