author | briangoetz |
Wed, 18 Dec 2013 16:05:18 -0500 | |
changeset 22163 | 3651128c74eb |
parent 21041 | 99f5e5e97425 |
child 23798 | ca0f80391182 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15385 | 2 |
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.code; |
|
27 |
||
28 |
import java.util.LinkedHashMap; |
|
29 |
import java.util.Map; |
|
30 |
import javax.lang.model.element.AnnotationMirror; |
|
31 |
import javax.lang.model.element.AnnotationValue; |
|
32 |
import javax.lang.model.element.AnnotationValueVisitor; |
|
33 |
import javax.lang.model.type.DeclaredType; |
|
34 |
import com.sun.tools.javac.code.Symbol.*; |
|
35 |
import com.sun.tools.javac.util.*; |
|
36 |
||
37 |
/** An annotation value. |
|
38 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
39 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
40 |
* If you write code that depends on this, you do so at your own risk. |
10 | 41 |
* This code and its internal interfaces are subject to change or |
42 |
* deletion without notice.</b> |
|
43 |
*/ |
|
44 |
public abstract class Attribute implements AnnotationValue { |
|
45 |
||
46 |
/** The type of the annotation element. */ |
|
47 |
public Type type; |
|
48 |
||
49 |
public Attribute(Type type) { |
|
50 |
this.type = type; |
|
51 |
} |
|
52 |
||
53 |
public abstract void accept(Visitor v); |
|
54 |
||
55 |
public Object getValue() { |
|
56 |
throw new UnsupportedOperationException(); |
|
57 |
} |
|
58 |
||
59 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
60 |
throw new UnsupportedOperationException(); |
|
61 |
} |
|
62 |
||
14961
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
63 |
public boolean isSynthesized() { |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
64 |
return false; |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
65 |
} |
10 | 66 |
|
22163 | 67 |
public TypeAnnotationPosition getPosition() { return null; } |
21010
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
68 |
|
10 | 69 |
/** The value for an annotation element of primitive type or String. */ |
70 |
public static class Constant extends Attribute { |
|
71 |
public final Object value; |
|
72 |
public void accept(Visitor v) { v.visitConstant(this); } |
|
73 |
public Constant(Type type, Object value) { |
|
74 |
super(type); |
|
75 |
this.value = value; |
|
76 |
} |
|
77 |
public String toString() { |
|
78 |
return Constants.format(value, type); |
|
79 |
} |
|
80 |
public Object getValue() { |
|
81 |
return Constants.decode(value, type); |
|
82 |
} |
|
83 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
84 |
if (value instanceof String) |
|
85 |
return v.visitString((String) value, p); |
|
86 |
if (value instanceof Integer) { |
|
87 |
int i = (Integer) value; |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
17578
diff
changeset
|
88 |
switch (type.getTag()) { |
10 | 89 |
case BOOLEAN: return v.visitBoolean(i != 0, p); |
90 |
case CHAR: return v.visitChar((char) i, p); |
|
91 |
case BYTE: return v.visitByte((byte) i, p); |
|
92 |
case SHORT: return v.visitShort((short) i, p); |
|
93 |
case INT: return v.visitInt(i, p); |
|
94 |
} |
|
95 |
} |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
17578
diff
changeset
|
96 |
switch (type.getTag()) { |
10 | 97 |
case LONG: return v.visitLong((Long) value, p); |
98 |
case FLOAT: return v.visitFloat((Float) value, p); |
|
99 |
case DOUBLE: return v.visitDouble((Double) value, p); |
|
100 |
} |
|
101 |
throw new AssertionError("Bad annotation element value: " + value); |
|
102 |
} |
|
103 |
} |
|
104 |
||
105 |
/** The value for an annotation element of type java.lang.Class, |
|
106 |
* represented as a ClassSymbol. |
|
107 |
*/ |
|
108 |
public static class Class extends Attribute { |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
109 |
public final Type classType; |
10 | 110 |
public void accept(Visitor v) { v.visitClass(this); } |
111 |
public Class(Types types, Type type) { |
|
112 |
super(makeClassType(types, type)); |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
113 |
this.classType = type; |
10 | 114 |
} |
115 |
static Type makeClassType(Types types, Type type) { |
|
116 |
Type arg = type.isPrimitive() |
|
117 |
? types.boxedClass(type).type |
|
118 |
: types.erasure(type); |
|
119 |
return new Type.ClassType(types.syms.classType.getEnclosingType(), |
|
120 |
List.of(arg), |
|
121 |
types.syms.classType.tsym); |
|
122 |
} |
|
123 |
public String toString() { |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
124 |
return classType + ".class"; |
10 | 125 |
} |
126 |
public Type getValue() { |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
127 |
return classType; |
10 | 128 |
} |
129 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
130 |
return v.visitType(classType, p); |
10 | 131 |
} |
132 |
} |
|
133 |
||
134 |
/** A compound annotation element value, the type of which is an |
|
135 |
* attribute interface. |
|
136 |
*/ |
|
137 |
public static class Compound extends Attribute implements AnnotationMirror { |
|
138 |
/** The attributes values, as pairs. Each pair contains a |
|
139 |
* reference to the accessing method in the attribute interface |
|
140 |
* and the value to be returned when that method is called to |
|
141 |
* access this attribute. |
|
142 |
*/ |
|
143 |
public final List<Pair<MethodSymbol,Attribute>> values; |
|
14961
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
144 |
|
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
145 |
private boolean synthesized = false; |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
146 |
|
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
147 |
@Override |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
148 |
public boolean isSynthesized() { |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
149 |
return synthesized; |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
150 |
} |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
151 |
|
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
152 |
public void setSynthesized(boolean synthesized) { |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
153 |
this.synthesized = synthesized; |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
154 |
} |
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14359
diff
changeset
|
155 |
|
10 | 156 |
public Compound(Type type, |
157 |
List<Pair<MethodSymbol,Attribute>> values) { |
|
158 |
super(type); |
|
159 |
this.values = values; |
|
160 |
} |
|
161 |
public void accept(Visitor v) { v.visitCompound(this); } |
|
162 |
||
163 |
/** |
|
164 |
* Returns a string representation of this annotation. |
|
165 |
* String is of one of the forms: |
|
166 |
* @com.example.foo(name1=val1, name2=val2) |
|
167 |
* @com.example.foo(val) |
|
168 |
* @com.example.foo |
|
169 |
* Omit parens for marker annotations, and omit "value=" when allowed. |
|
170 |
*/ |
|
171 |
public String toString() { |
|
172 |
StringBuilder buf = new StringBuilder(); |
|
173 |
buf.append("@"); |
|
174 |
buf.append(type); |
|
175 |
int len = values.length(); |
|
176 |
if (len > 0) { |
|
177 |
buf.append('('); |
|
178 |
boolean first = true; |
|
179 |
for (Pair<MethodSymbol, Attribute> value : values) { |
|
180 |
if (!first) buf.append(", "); |
|
181 |
first = false; |
|
182 |
||
183 |
Name name = value.fst.name; |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1206
diff
changeset
|
184 |
if (len > 1 || name != name.table.names.value) { |
10 | 185 |
buf.append(name); |
186 |
buf.append('='); |
|
187 |
} |
|
188 |
buf.append(value.snd); |
|
189 |
} |
|
190 |
buf.append(')'); |
|
191 |
} |
|
192 |
return buf.toString(); |
|
193 |
} |
|
194 |
||
195 |
public Attribute member(Name member) { |
|
21010
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
196 |
Pair<MethodSymbol,Attribute> res = getElemPair(member); |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
197 |
return res == null ? null : res.snd; |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
198 |
} |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
199 |
|
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
200 |
private Pair<MethodSymbol, Attribute> getElemPair(Name member) { |
10 | 201 |
for (Pair<MethodSymbol,Attribute> pair : values) |
21010
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
202 |
if (pair.fst.name == member) return pair; |
10 | 203 |
return null; |
204 |
} |
|
205 |
||
206 |
public Attribute.Compound getValue() { |
|
207 |
return this; |
|
208 |
} |
|
209 |
||
210 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
211 |
return v.visitAnnotation(this, p); |
|
212 |
} |
|
213 |
||
214 |
public DeclaredType getAnnotationType() { |
|
215 |
return (DeclaredType) type; |
|
216 |
} |
|
217 |
||
21010
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
218 |
@Override |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
219 |
public TypeAnnotationPosition getPosition() { |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
220 |
if (values.size() != 0) { |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
221 |
Name valueName = values.head.fst.name.table.names.value; |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
222 |
Pair<MethodSymbol, Attribute> res = getElemPair(valueName); |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
223 |
return res == null ? null : res.snd.getPosition(); |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
224 |
} |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
225 |
return null; |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
226 |
} |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
227 |
|
10 | 228 |
public Map<MethodSymbol, Attribute> getElementValues() { |
22163 | 229 |
Map<MethodSymbol, Attribute> valmap = new LinkedHashMap<>(); |
10 | 230 |
for (Pair<MethodSymbol, Attribute> value : values) |
231 |
valmap.put(value.fst, value.snd); |
|
232 |
return valmap; |
|
233 |
} |
|
234 |
} |
|
235 |
||
15385 | 236 |
public static class TypeCompound extends Compound { |
237 |
public TypeAnnotationPosition position; |
|
21041 | 238 |
|
15385 | 239 |
public TypeCompound(Compound compound, |
240 |
TypeAnnotationPosition position) { |
|
241 |
this(compound.type, compound.values, position); |
|
242 |
} |
|
243 |
public TypeCompound(Type type, |
|
244 |
List<Pair<MethodSymbol, Attribute>> values, |
|
245 |
TypeAnnotationPosition position) { |
|
246 |
super(type, values); |
|
247 |
this.position = position; |
|
248 |
} |
|
249 |
||
21010
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
250 |
@Override |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
251 |
public TypeAnnotationPosition getPosition() { |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
252 |
if (hasUnknownPosition()) { |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
253 |
position = super.getPosition(); |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
254 |
} |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
255 |
return position; |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
256 |
} |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
257 |
|
17578 | 258 |
public boolean hasUnknownPosition() { |
21041 | 259 |
return position.type == TargetType.UNKNOWN; |
17578 | 260 |
} |
261 |
||
262 |
public boolean isContainerTypeCompound() { |
|
263 |
if (isSynthesized() && values.size() == 1) |
|
264 |
return getFirstEmbeddedTC() != null; |
|
265 |
return false; |
|
266 |
} |
|
267 |
||
268 |
private TypeCompound getFirstEmbeddedTC() { |
|
269 |
if (values.size() == 1) { |
|
270 |
Pair<MethodSymbol, Attribute> val = values.get(0); |
|
271 |
if (val.fst.getSimpleName().contentEquals("value") |
|
272 |
&& val.snd instanceof Array) { |
|
273 |
Array arr = (Array) val.snd; |
|
274 |
if (arr.values.length != 0 |
|
275 |
&& arr.values[0] instanceof Attribute.TypeCompound) |
|
276 |
return (Attribute.TypeCompound) arr.values[0]; |
|
277 |
} |
|
278 |
} |
|
279 |
return null; |
|
280 |
} |
|
281 |
||
282 |
public boolean tryFixPosition() { |
|
283 |
if (!isContainerTypeCompound()) |
|
284 |
return false; |
|
285 |
||
286 |
TypeCompound from = getFirstEmbeddedTC(); |
|
287 |
if (from != null && from.position != null && |
|
288 |
from.position.type != TargetType.UNKNOWN) { |
|
289 |
position = from.position; |
|
290 |
return true; |
|
291 |
} |
|
292 |
return false; |
|
293 |
} |
|
15385 | 294 |
} |
295 |
||
10 | 296 |
/** The value for an annotation element of an array type. |
297 |
*/ |
|
298 |
public static class Array extends Attribute { |
|
299 |
public final Attribute[] values; |
|
300 |
public Array(Type type, Attribute[] values) { |
|
301 |
super(type); |
|
302 |
this.values = values; |
|
303 |
} |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
304 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
305 |
public Array(Type type, List<Attribute> values) { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
306 |
super(type); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
307 |
this.values = values.toArray(new Attribute[values.size()]); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
308 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
8032
diff
changeset
|
309 |
|
10 | 310 |
public void accept(Visitor v) { v.visitArray(this); } |
311 |
public String toString() { |
|
312 |
StringBuilder buf = new StringBuilder(); |
|
313 |
buf.append('{'); |
|
314 |
boolean first = true; |
|
315 |
for (Attribute value : values) { |
|
316 |
if (!first) |
|
317 |
buf.append(", "); |
|
318 |
first = false; |
|
319 |
buf.append(value); |
|
320 |
} |
|
321 |
buf.append('}'); |
|
322 |
return buf.toString(); |
|
323 |
} |
|
324 |
public List<Attribute> getValue() { |
|
325 |
return List.from(values); |
|
326 |
} |
|
327 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
328 |
return v.visitArray(getValue(), p); |
|
329 |
} |
|
21010
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
330 |
|
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
331 |
@Override |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
332 |
public TypeAnnotationPosition getPosition() { |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
333 |
if (values.length != 0) |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
334 |
return values[0].getPosition(); |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
335 |
else |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
336 |
return null; |
5ffe0d8a5e24
8008762: Type annotation on inner class in anonymous class show up as regular type annotations
emc
parents:
19507
diff
changeset
|
337 |
} |
10 | 338 |
} |
339 |
||
340 |
/** The value for an annotation element of an enum type. |
|
341 |
*/ |
|
342 |
public static class Enum extends Attribute { |
|
343 |
public VarSymbol value; |
|
344 |
public Enum(Type type, VarSymbol value) { |
|
345 |
super(type); |
|
8032 | 346 |
this.value = Assert.checkNonNull(value); |
10 | 347 |
} |
348 |
public void accept(Visitor v) { v.visitEnum(this); } |
|
349 |
public String toString() { |
|
350 |
return value.enclClass() + "." + value; // qualified name |
|
351 |
} |
|
352 |
public VarSymbol getValue() { |
|
353 |
return value; |
|
354 |
} |
|
355 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
356 |
return v.visitEnumConstant(value, p); |
|
357 |
} |
|
358 |
} |
|
359 |
||
360 |
public static class Error extends Attribute { |
|
361 |
public Error(Type type) { |
|
362 |
super(type); |
|
363 |
} |
|
364 |
public void accept(Visitor v) { v.visitError(this); } |
|
365 |
public String toString() { |
|
366 |
return "<error>"; |
|
367 |
} |
|
368 |
public String getValue() { |
|
369 |
return toString(); |
|
370 |
} |
|
371 |
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) { |
|
372 |
return v.visitString(toString(), p); |
|
373 |
} |
|
374 |
} |
|
375 |
||
19507
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
376 |
public static class UnresolvedClass extends Error { |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
377 |
public Type classType; |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
378 |
public UnresolvedClass(Type type, Type classType) { |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
379 |
super(type); |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
380 |
this.classType = classType; |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
381 |
} |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
382 |
} |
323f001d6be1
8019243: AnnotationTypeMismatchException instead of MirroredTypeException
jfranck
parents:
18646
diff
changeset
|
383 |
|
10 | 384 |
/** A visitor type for dynamic dispatch on the kind of attribute value. */ |
385 |
public static interface Visitor { |
|
386 |
void visitConstant(Attribute.Constant value); |
|
387 |
void visitClass(Attribute.Class clazz); |
|
388 |
void visitCompound(Attribute.Compound compound); |
|
389 |
void visitArray(Attribute.Array array); |
|
390 |
void visitEnum(Attribute.Enum e); |
|
391 |
void visitError(Attribute.Error e); |
|
392 |
} |
|
6575
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
393 |
|
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
394 |
/** A mirror of java.lang.annotation.RetentionPolicy. */ |
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
395 |
public static enum RetentionPolicy { |
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
396 |
SOURCE, |
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
397 |
CLASS, |
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
398 |
RUNTIME |
ae1798028008
6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents:
5847
diff
changeset
|
399 |
} |
10 | 400 |
} |