author | coleenp |
Tue, 22 Dec 2015 11:11:29 -0500 | |
changeset 35214 | d86005e0b4c2 |
parent 30846 | 2b3f379840f0 |
permissions | -rw-r--r-- |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
1 |
/* |
15385 | 2 |
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
4 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
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 |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
10 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
16 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
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. |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
24 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
25 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
26 |
package com.sun.tools.javap; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
27 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
28 |
import com.sun.tools.classfile.Annotation; |
15385 | 29 |
import com.sun.tools.classfile.TypeAnnotation; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
30 |
import com.sun.tools.classfile.Annotation.Annotation_element_value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
31 |
import com.sun.tools.classfile.Annotation.Array_element_value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
32 |
import com.sun.tools.classfile.Annotation.Class_element_value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
33 |
import com.sun.tools.classfile.Annotation.Enum_element_value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
34 |
import com.sun.tools.classfile.Annotation.Primitive_element_value; |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
35 |
import com.sun.tools.classfile.ConstantPool; |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
36 |
import com.sun.tools.classfile.ConstantPoolException; |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
37 |
import com.sun.tools.classfile.Descriptor; |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
38 |
import com.sun.tools.classfile.Descriptor.InvalidDescriptor; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
39 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
40 |
/** |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
41 |
* A writer for writing annotations as text. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
42 |
* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
43 |
* <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
|
44 |
* If you write code that depends on this, you do so at your own risk. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
45 |
* This code and its internal interfaces are subject to change or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
46 |
* deletion without notice.</b> |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
47 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
48 |
public class AnnotationWriter extends BasicWriter { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
49 |
static AnnotationWriter instance(Context context) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
50 |
AnnotationWriter instance = context.get(AnnotationWriter.class); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
51 |
if (instance == null) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
52 |
instance = new AnnotationWriter(context); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
53 |
return instance; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
54 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
55 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
56 |
protected AnnotationWriter(Context context) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
57 |
super(context); |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
58 |
classWriter = ClassWriter.instance(context); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
59 |
constantWriter = ConstantWriter.instance(context); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
60 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
61 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
62 |
public void write(Annotation annot) { |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
63 |
write(annot, false); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
64 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
65 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
66 |
public void write(Annotation annot, boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
67 |
writeDescriptor(annot.type_index, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
68 |
boolean showParens = annot.num_element_value_pairs > 0 || !resolveIndices; |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
69 |
if (showParens) |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
70 |
print("("); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
71 |
for (int i = 0; i < annot.num_element_value_pairs; i++) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
72 |
if (i > 0) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
73 |
print(","); |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
74 |
write(annot.element_value_pairs[i], resolveIndices); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
75 |
} |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
76 |
if (showParens) |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
77 |
print(")"); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
78 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
79 |
|
15385 | 80 |
public void write(TypeAnnotation annot) { |
81 |
write(annot, true, false); |
|
82 |
} |
|
83 |
||
84 |
public void write(TypeAnnotation annot, boolean showOffsets, boolean resolveIndices) { |
|
85 |
write(annot.annotation, resolveIndices); |
|
86 |
print(": "); |
|
87 |
write(annot.position, showOffsets); |
|
88 |
} |
|
89 |
||
90 |
public void write(TypeAnnotation.Position pos, boolean showOffsets) { |
|
91 |
print(pos.type); |
|
92 |
||
93 |
switch (pos.type) { |
|
94 |
// instanceof |
|
95 |
case INSTANCEOF: |
|
96 |
// new expression |
|
97 |
case NEW: |
|
15718 | 98 |
// constructor/method reference receiver |
99 |
case CONSTRUCTOR_REFERENCE: |
|
100 |
case METHOD_REFERENCE: |
|
15385 | 101 |
if (showOffsets) { |
102 |
print(", offset="); |
|
103 |
print(pos.offset); |
|
104 |
} |
|
105 |
break; |
|
106 |
// local variable |
|
107 |
case LOCAL_VARIABLE: |
|
108 |
// resource variable |
|
109 |
case RESOURCE_VARIABLE: |
|
110 |
if (pos.lvarOffset == null) { |
|
111 |
print(", lvarOffset is Null!"); |
|
112 |
break; |
|
113 |
} |
|
114 |
print(", {"); |
|
115 |
for (int i = 0; i < pos.lvarOffset.length; ++i) { |
|
116 |
if (i != 0) print("; "); |
|
117 |
if (showOffsets) { |
|
118 |
print("start_pc="); |
|
119 |
print(pos.lvarOffset[i]); |
|
120 |
} |
|
121 |
print(", length="); |
|
122 |
print(pos.lvarLength[i]); |
|
123 |
print(", index="); |
|
124 |
print(pos.lvarIndex[i]); |
|
125 |
} |
|
126 |
print("}"); |
|
127 |
break; |
|
128 |
// exception parameter |
|
129 |
case EXCEPTION_PARAMETER: |
|
130 |
print(", exception_index="); |
|
131 |
print(pos.exception_index); |
|
132 |
break; |
|
133 |
// method receiver |
|
134 |
case METHOD_RECEIVER: |
|
135 |
// Do nothing |
|
136 |
break; |
|
137 |
// type parameter |
|
138 |
case CLASS_TYPE_PARAMETER: |
|
139 |
case METHOD_TYPE_PARAMETER: |
|
140 |
print(", param_index="); |
|
141 |
print(pos.parameter_index); |
|
142 |
break; |
|
143 |
// type parameter bound |
|
144 |
case CLASS_TYPE_PARAMETER_BOUND: |
|
145 |
case METHOD_TYPE_PARAMETER_BOUND: |
|
146 |
print(", param_index="); |
|
147 |
print(pos.parameter_index); |
|
148 |
print(", bound_index="); |
|
149 |
print(pos.bound_index); |
|
150 |
break; |
|
151 |
// class extends or implements clause |
|
152 |
case CLASS_EXTENDS: |
|
153 |
print(", type_index="); |
|
154 |
print(pos.type_index); |
|
155 |
break; |
|
156 |
// throws |
|
157 |
case THROWS: |
|
158 |
print(", type_index="); |
|
159 |
print(pos.type_index); |
|
160 |
break; |
|
161 |
// method parameter |
|
162 |
case METHOD_FORMAL_PARAMETER: |
|
163 |
print(", param_index="); |
|
164 |
print(pos.parameter_index); |
|
165 |
break; |
|
15718 | 166 |
// type cast |
167 |
case CAST: |
|
15385 | 168 |
// method/constructor/reference type argument |
169 |
case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT: |
|
170 |
case METHOD_INVOCATION_TYPE_ARGUMENT: |
|
15718 | 171 |
case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT: |
15385 | 172 |
case METHOD_REFERENCE_TYPE_ARGUMENT: |
173 |
if (showOffsets) { |
|
174 |
print(", offset="); |
|
175 |
print(pos.offset); |
|
176 |
} |
|
177 |
print(", type_index="); |
|
178 |
print(pos.type_index); |
|
179 |
break; |
|
180 |
// We don't need to worry about these |
|
181 |
case METHOD_RETURN: |
|
182 |
case FIELD: |
|
183 |
break; |
|
184 |
case UNKNOWN: |
|
185 |
throw new AssertionError("AnnotationWriter: UNKNOWN target type should never occur!"); |
|
186 |
default: |
|
187 |
throw new AssertionError("AnnotationWriter: Unknown target type for position: " + pos); |
|
188 |
} |
|
189 |
||
190 |
// Append location data for generics/arrays. |
|
191 |
if (!pos.location.isEmpty()) { |
|
192 |
print(", location="); |
|
193 |
print(pos.location); |
|
194 |
} |
|
195 |
} |
|
196 |
||
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
197 |
public void write(Annotation.element_value_pair pair) { |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
198 |
write(pair, false); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
199 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
200 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
201 |
public void write(Annotation.element_value_pair pair, boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
202 |
writeIndex(pair.element_name_index, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
203 |
print("="); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
204 |
write(pair.value, resolveIndices); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
205 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
206 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
207 |
public void write(Annotation.element_value value) { |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
208 |
write(value, false); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
209 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
210 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
211 |
public void write(Annotation.element_value value, boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
212 |
ev_writer.write(value, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
213 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
214 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
215 |
private void writeDescriptor(int index, boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
216 |
if (resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
217 |
try { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
218 |
ConstantPool constant_pool = classWriter.getClassFile().constant_pool; |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
219 |
Descriptor d = new Descriptor(index); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
220 |
print(d.getFieldType(constant_pool)); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
221 |
return; |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
15718
diff
changeset
|
222 |
} catch (ConstantPoolException | InvalidDescriptor ignore) { |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
223 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
224 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
225 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
226 |
print("#" + index); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
227 |
} |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
228 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
229 |
private void writeIndex(int index, boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
230 |
if (resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
231 |
print(constantWriter.stringValue(index)); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
232 |
} else |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
233 |
print("#" + index); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
234 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
235 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
236 |
element_value_Writer ev_writer = new element_value_Writer(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
237 |
|
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
238 |
class element_value_Writer implements Annotation.element_value.Visitor<Void,Boolean> { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
239 |
public void write(Annotation.element_value value, boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
240 |
value.accept(this, resolveIndices); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
241 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
242 |
|
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
243 |
public Void visitPrimitive(Primitive_element_value ev, Boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
244 |
if (resolveIndices) |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
245 |
writeIndex(ev.const_value_index, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
246 |
else |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
247 |
print(((char) ev.tag) + "#" + ev.const_value_index); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
248 |
return null; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
249 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
250 |
|
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
251 |
public Void visitEnum(Enum_element_value ev, Boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
252 |
if (resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
253 |
writeIndex(ev.type_name_index, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
254 |
print("."); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
255 |
writeIndex(ev.const_name_index, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
256 |
} else |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
257 |
print(((char) ev.tag) + "#" + ev.type_name_index + ".#" + ev.const_name_index); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
258 |
return null; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
259 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
260 |
|
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
261 |
public Void visitClass(Class_element_value ev, Boolean resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
262 |
if (resolveIndices) { |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
263 |
writeIndex(ev.class_info_index, resolveIndices); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
264 |
print(".class"); |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
265 |
} else |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
266 |
print(((char) ev.tag) + "#" + ev.class_info_index); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
267 |
return null; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
268 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
269 |
|
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
270 |
public Void visitAnnotation(Annotation_element_value ev, Boolean resolveIndices) { |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
271 |
print((char) ev.tag); |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
272 |
AnnotationWriter.this.write(ev.annotation_value, resolveIndices); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
273 |
return null; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
274 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
275 |
|
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
276 |
public Void visitArray(Array_element_value ev, Boolean resolveIndices) { |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
277 |
print("["); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
278 |
for (int i = 0; i < ev.num_values; i++) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
279 |
if (i > 0) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
280 |
print(","); |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
281 |
write(ev.values[i], resolveIndices); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
282 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
283 |
print("]"); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
284 |
return null; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
285 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
286 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
287 |
} |
3536
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
288 |
|
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
289 |
private ClassWriter classWriter; |
dee1b5833af7
6855990: javap InstructionDetailWriter should support new 308 annotations attribute
jjg
parents:
3149
diff
changeset
|
290 |
private ConstantWriter constantWriter; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
291 |
} |