src/share/classes/com/sun/tools/javap/AttributeWriter.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
1 /*
2 * Copyright (c) 2007, 2013, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25
26 package com.sun.tools.javap;
27
28 import java.util.Formatter;
29
30 import com.sun.tools.classfile.AccessFlags;
31 import com.sun.tools.classfile.AnnotationDefault_attribute;
32 import com.sun.tools.classfile.Attribute;
33 import com.sun.tools.classfile.Attributes;
34 import com.sun.tools.classfile.BootstrapMethods_attribute;
35 import com.sun.tools.classfile.CharacterRangeTable_attribute;
36 import com.sun.tools.classfile.Code_attribute;
37 import com.sun.tools.classfile.CompilationID_attribute;
38 import com.sun.tools.classfile.ConstantPool;
39 import com.sun.tools.classfile.ConstantPoolException;
40 import com.sun.tools.classfile.ConstantValue_attribute;
41 import com.sun.tools.classfile.DefaultAttribute;
42 import com.sun.tools.classfile.Deprecated_attribute;
43 import com.sun.tools.classfile.EnclosingMethod_attribute;
44 import com.sun.tools.classfile.Exceptions_attribute;
45 import com.sun.tools.classfile.InnerClasses_attribute;
46 import com.sun.tools.classfile.LineNumberTable_attribute;
47 import com.sun.tools.classfile.LocalVariableTable_attribute;
48 import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
49 import com.sun.tools.classfile.MethodParameters_attribute;
50 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
51 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
52 import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
53 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
54 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
55 import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
56 import com.sun.tools.classfile.Signature_attribute;
57 import com.sun.tools.classfile.SourceDebugExtension_attribute;
58 import com.sun.tools.classfile.SourceFile_attribute;
59 import com.sun.tools.classfile.SourceID_attribute;
60 import com.sun.tools.classfile.StackMapTable_attribute;
61 import com.sun.tools.classfile.StackMap_attribute;
62 import com.sun.tools.classfile.Synthetic_attribute;
63
64 import static com.sun.tools.classfile.AccessFlags.*;
65 import com.sun.tools.javac.util.StringUtils;
66
67 /*
68 * A writer for writing Attributes as text.
69 *
70 * <p><b>This is NOT part of any supported API.
71 * If you write code that depends on this, you do so at your own risk.
72 * This code and its internal interfaces are subject to change or
73 * deletion without notice.</b>
74 */
75 public class AttributeWriter extends BasicWriter
76 implements Attribute.Visitor<Void,Void>
77 {
78 public static AttributeWriter instance(Context context) {
79 AttributeWriter instance = context.get(AttributeWriter.class);
80 if (instance == null)
81 instance = new AttributeWriter(context);
82 return instance;
83 }
84
85 protected AttributeWriter(Context context) {
86 super(context);
87 context.put(AttributeWriter.class, this);
88 annotationWriter = AnnotationWriter.instance(context);
89 codeWriter = CodeWriter.instance(context);
90 constantWriter = ConstantWriter.instance(context);
91 options = Options.instance(context);
92 }
93
94 public void write(Object owner, Attribute attr, ConstantPool constant_pool) {
95 if (attr != null) {
96 // null checks
97 owner.getClass();
98 constant_pool.getClass();
99 this.constant_pool = constant_pool;
100 this.owner = owner;
101 attr.accept(this, null);
102 }
103 }
104
105 public void write(Object owner, Attributes attrs, ConstantPool constant_pool) {
106 if (attrs != null) {
107 // null checks
108 owner.getClass();
109 constant_pool.getClass();
110 this.constant_pool = constant_pool;
111 this.owner = owner;
112 for (Attribute attr: attrs)
113 attr.accept(this, null);
114 }
115 }
116
117 public Void visitDefault(DefaultAttribute attr, Void ignore) {
118 if (attr.reason != null) {
119 report(attr.reason);
120 }
121 byte[] data = attr.info;
122 int i = 0;
123 int j = 0;
124 print(" ");
125 try {
126 print(attr.getName(constant_pool));
127 } catch (ConstantPoolException e) {
128 report(e);
129 print("attribute name = #" + attr.attribute_name_index);
130 }
131 print(": ");
132 println("length = 0x" + toHex(attr.info.length));
133
134 print(" ");
135
136 while (i < data.length) {
137 print(toHex(data[i], 2));
138
139 j++;
140 if (j == 16) {
141 println();
142 print(" ");
143 j = 0;
144 } else {
145 print(" ");
146 }
147 i++;
148 }
149 println();
150 return null;
151 }
152
153 public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) {
154 println("AnnotationDefault:");
155 indent(+1);
156 print("default_value: ");
157 annotationWriter.write(attr.default_value);
158 indent(-1);
159 return null;
160 }
161
162 public Void visitBootstrapMethods(BootstrapMethods_attribute attr, Void p) {
163 println(Attribute.BootstrapMethods + ":");
164 for (int i = 0; i < attr.bootstrap_method_specifiers.length ; i++) {
165 BootstrapMethods_attribute.BootstrapMethodSpecifier bsm = attr.bootstrap_method_specifiers[i];
166 indent(+1);
167 print(i + ": #" + bsm.bootstrap_method_ref + " ");
168 println(constantWriter.stringValue(bsm.bootstrap_method_ref));
169 indent(+1);
170 println("Method arguments:");
171 indent(+1);
172 for (int j = 0; j < bsm.bootstrap_arguments.length; j++) {
173 print("#" + bsm.bootstrap_arguments[j] + " ");
174 println(constantWriter.stringValue(bsm.bootstrap_arguments[j]));
175 }
176 indent(-3);
177 }
178 return null;
179 }
180
181 public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) {
182 println("CharacterRangeTable:");
183 indent(+1);
184 for (int i = 0; i < attr.character_range_table.length; i++) {
185 CharacterRangeTable_attribute.Entry e = attr.character_range_table[i];
186 print(String.format(" %2d, %2d, %6x, %6x, %4x",
187 e.start_pc, e.end_pc,
188 e.character_range_start, e.character_range_end,
189 e.flags));
190 tab();
191 print(String.format("// %2d, %2d, %4d:%02d, %4d:%02d",
192 e.start_pc, e.end_pc,
193 (e.character_range_start >> 10), (e.character_range_start & 0x3ff),
194 (e.character_range_end >> 10), (e.character_range_end & 0x3ff)));
195 if ((e.flags & CharacterRangeTable_attribute.CRT_STATEMENT) != 0)
196 print(", statement");
197 if ((e.flags & CharacterRangeTable_attribute.CRT_BLOCK) != 0)
198 print(", block");
199 if ((e.flags & CharacterRangeTable_attribute.CRT_ASSIGNMENT) != 0)
200 print(", assignment");
201 if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_CONTROLLER) != 0)
202 print(", flow-controller");
203 if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_TARGET) != 0)
204 print(", flow-target");
205 if ((e.flags & CharacterRangeTable_attribute.CRT_INVOKE) != 0)
206 print(", invoke");
207 if ((e.flags & CharacterRangeTable_attribute.CRT_CREATE) != 0)
208 print(", create");
209 if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_TRUE) != 0)
210 print(", branch-true");
211 if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0)
212 print(", branch-false");
213 println();
214 }
215 indent(-1);
216 return null;
217 }
218
219 public Void visitCode(Code_attribute attr, Void ignore) {
220 codeWriter.write(attr, constant_pool);
221 return null;
222 }
223
224 public Void visitCompilationID(CompilationID_attribute attr, Void ignore) {
225 constantWriter.write(attr.compilationID_index);
226 return null;
227 }
228
229 public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
230 print("ConstantValue: ");
231 constantWriter.write(attr.constantvalue_index);
232 println();
233 return null;
234 }
235
236 public Void visitDeprecated(Deprecated_attribute attr, Void ignore) {
237 println("Deprecated: true");
238 return null;
239 }
240
241 public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) {
242 print("EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index);
243 tab();
244 print("// " + getJavaClassName(attr));
245 if (attr.method_index != 0)
246 print("." + getMethodName(attr));
247 println();
248 return null;
249 }
250
251 private String getJavaClassName(EnclosingMethod_attribute a) {
252 try {
253 return getJavaName(a.getClassName(constant_pool));
254 } catch (ConstantPoolException e) {
255 return report(e);
256 }
257 }
258
259 private String getMethodName(EnclosingMethod_attribute a) {
260 try {
261 return a.getMethodName(constant_pool);
262 } catch (ConstantPoolException e) {
263 return report(e);
264 }
265 }
266
267 public Void visitExceptions(Exceptions_attribute attr, Void ignore) {
268 println("Exceptions:");
269 indent(+1);
270 print("throws ");
271 for (int i = 0; i < attr.number_of_exceptions; i++) {
272 if (i > 0)
273 print(", ");
274 print(getJavaException(attr, i));
275 }
276 println();
277 indent(-1);
278 return null;
279 }
280
281 private String getJavaException(Exceptions_attribute attr, int index) {
282 try {
283 return getJavaName(attr.getException(index, constant_pool));
284 } catch (ConstantPoolException e) {
285 return report(e);
286 }
287 }
288
289 public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
290 boolean first = true;
291 for (int i = 0 ; i < attr.classes.length; i++) {
292 InnerClasses_attribute.Info info = attr.classes[i];
293 //access
294 AccessFlags access_flags = info.inner_class_access_flags;
295 if (options.checkAccess(access_flags)) {
296 if (first) {
297 writeInnerClassHeader();
298 first = false;
299 }
300 print(" ");
301 for (String name: access_flags.getInnerClassModifiers())
302 print(name + " ");
303 if (info.inner_name_index!=0) {
304 print("#" + info.inner_name_index + "= ");
305 }
306 print("#" + info.inner_class_info_index);
307 if (info.outer_class_info_index != 0) {
308 print(" of #" + info.outer_class_info_index);
309 }
310 print("; //");
311 if (info.inner_name_index != 0) {
312 print(getInnerName(constant_pool, info) + "=");
313 }
314 constantWriter.write(info.inner_class_info_index);
315 if (info.outer_class_info_index != 0) {
316 print(" of ");
317 constantWriter.write(info.outer_class_info_index);
318 }
319 println();
320 }
321 }
322 if (!first)
323 indent(-1);
324 return null;
325 }
326
327 String getInnerName(ConstantPool constant_pool, InnerClasses_attribute.Info info) {
328 try {
329 return info.getInnerName(constant_pool);
330 } catch (ConstantPoolException e) {
331 return report(e);
332 }
333 }
334
335 private void writeInnerClassHeader() {
336 println("InnerClasses:");
337 indent(+1);
338 }
339
340 public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) {
341 println("LineNumberTable:");
342 indent(+1);
343 for (LineNumberTable_attribute.Entry entry: attr.line_number_table) {
344 println("line " + entry.line_number + ": " + entry.start_pc);
345 }
346 indent(-1);
347 return null;
348 }
349
350 public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) {
351 println("LocalVariableTable:");
352 indent(+1);
353 println("Start Length Slot Name Signature");
354 for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
355 println(String.format("%5d %7d %5d %5s %s",
356 entry.start_pc, entry.length, entry.index,
357 constantWriter.stringValue(entry.name_index),
358 constantWriter.stringValue(entry.descriptor_index)));
359 }
360 indent(-1);
361 return null;
362 }
363
364 public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) {
365 println("LocalVariableTypeTable:");
366 indent(+1);
367 println("Start Length Slot Name Signature");
368 for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) {
369 println(String.format("%5d %7d %5d %5s %s",
370 entry.start_pc, entry.length, entry.index,
371 constantWriter.stringValue(entry.name_index),
372 constantWriter.stringValue(entry.signature_index)));
373 }
374 indent(-1);
375 return null;
376 }
377
378 private static final String format = "%-31s%s";
379
380 public Void visitMethodParameters(MethodParameters_attribute attr,
381 Void ignore) {
382
383 final String header = String.format(format, "Name", "Flags");
384 println("MethodParameters:");
385 indent(+1);
386 println(header);
387 for (MethodParameters_attribute.Entry entry :
388 attr.method_parameter_table) {
389 String namestr =
390 entry.name_index != 0 ?
391 constantWriter.stringValue(entry.name_index) : "<no name>";
392 String flagstr =
393 (0 != (entry.flags & ACC_FINAL) ? "final " : "") +
394 (0 != (entry.flags & ACC_MANDATED) ? "mandated " : "") +
395 (0 != (entry.flags & ACC_SYNTHETIC) ? "synthetic" : "");
396 println(String.format(format, namestr, flagstr));
397 }
398 indent(-1);
399 return null;
400 }
401
402 public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
403 println("RuntimeVisibleAnnotations:");
404 indent(+1);
405 for (int i = 0; i < attr.annotations.length; i++) {
406 print(i + ": ");
407 annotationWriter.write(attr.annotations[i]);
408 println();
409 }
410 indent(-1);
411 return null;
412 }
413
414 public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) {
415 println("RuntimeInvisibleAnnotations:");
416 indent(+1);
417 for (int i = 0; i < attr.annotations.length; i++) {
418 print(i + ": ");
419 annotationWriter.write(attr.annotations[i]);
420 println();
421 }
422 indent(-1);
423 return null;
424 }
425
426 public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, Void ignore) {
427 println("RuntimeVisibleTypeAnnotations:");
428 indent(+1);
429 for (int i = 0; i < attr.annotations.length; i++) {
430 print(i + ": ");
431 annotationWriter.write(attr.annotations[i]);
432 println();
433 }
434 indent(-1);
435 return null;
436 }
437
438 public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, Void ignore) {
439 println("RuntimeInvisibleTypeAnnotations:");
440 indent(+1);
441 for (int i = 0; i < attr.annotations.length; i++) {
442 print(i + ": ");
443 annotationWriter.write(attr.annotations[i]);
444 println();
445 }
446 indent(-1);
447 return null;
448 }
449
450 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
451 println("RuntimeVisibleParameterAnnotations:");
452 indent(+1);
453 for (int param = 0; param < attr.parameter_annotations.length; param++) {
454 println("parameter " + param + ": ");
455 indent(+1);
456 for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
457 print(i + ": ");
458 annotationWriter.write(attr.parameter_annotations[param][i]);
459 println();
460 }
461 indent(-1);
462 }
463 indent(-1);
464 return null;
465 }
466
467 public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) {
468 println("RuntimeInvisibleParameterAnnotations:");
469 indent(+1);
470 for (int param = 0; param < attr.parameter_annotations.length; param++) {
471 println(param + ": ");
472 indent(+1);
473 for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
474 print(i + ": ");
475 annotationWriter.write(attr.parameter_annotations[param][i]);
476 println();
477 }
478 indent(-1);
479 }
480 indent(-1);
481 return null;
482 }
483
484 public Void visitSignature(Signature_attribute attr, Void ignore) {
485 print("Signature: #" + attr.signature_index);
486 tab();
487 println("// " + getSignature(attr));
488 return null;
489 }
490
491 String getSignature(Signature_attribute info) {
492 try {
493 return info.getSignature(constant_pool);
494 } catch (ConstantPoolException e) {
495 return report(e);
496 }
497 }
498
499 public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
500 println("SourceDebugExtension:");
501 indent(+1);
502 for (String s: attr.getValue().split("[\r\n]+")) {
503 println(s);
504 }
505 indent(-1);
506 return null;
507 }
508
509 public Void visitSourceFile(SourceFile_attribute attr, Void ignore) {
510 println("SourceFile: \"" + getSourceFile(attr) + "\"");
511 return null;
512 }
513
514 private String getSourceFile(SourceFile_attribute attr) {
515 try {
516 return attr.getSourceFile(constant_pool);
517 } catch (ConstantPoolException e) {
518 return report(e);
519 }
520 }
521
522 public Void visitSourceID(SourceID_attribute attr, Void ignore) {
523 constantWriter.write(attr.sourceID_index);
524 return null;
525 }
526
527 public Void visitStackMap(StackMap_attribute attr, Void ignore) {
528 println("StackMap: number_of_entries = " + attr.number_of_entries);
529 indent(+1);
530 StackMapTableWriter w = new StackMapTableWriter();
531 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
532 w.write(entry);
533 }
534 indent(-1);
535 return null;
536 }
537
538 public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) {
539 println("StackMapTable: number_of_entries = " + attr.number_of_entries);
540 indent(+1);
541 StackMapTableWriter w = new StackMapTableWriter();
542 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
543 w.write(entry);
544 }
545 indent(-1);
546 return null;
547 }
548
549 class StackMapTableWriter // also handles CLDC StackMap attributes
550 implements StackMapTable_attribute.stack_map_frame.Visitor<Void,Void> {
551 public void write(StackMapTable_attribute.stack_map_frame frame) {
552 frame.accept(this, null);
553 }
554
555 public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
556 printHeader(frame, "/* same */");
557 return null;
558 }
559
560 public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
561 printHeader(frame, "/* same_locals_1_stack_item */");
562 indent(+1);
563 printMap("stack", frame.stack);
564 indent(-1);
565 return null;
566 }
567
568 public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
569 printHeader(frame, "/* same_locals_1_stack_item_frame_extended */");
570 indent(+1);
571 println("offset_delta = " + frame.offset_delta);
572 printMap("stack", frame.stack);
573 indent(-1);
574 return null;
575 }
576
577 public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
578 printHeader(frame, "/* chop */");
579 indent(+1);
580 println("offset_delta = " + frame.offset_delta);
581 indent(-1);
582 return null;
583 }
584
585 public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
586 printHeader(frame, "/* same_frame_extended */");
587 indent(+1);
588 println("offset_delta = " + frame.offset_delta);
589 indent(-1);
590 return null;
591 }
592
593 public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
594 printHeader(frame, "/* append */");
595 indent(+1);
596 println("offset_delta = " + frame.offset_delta);
597 printMap("locals", frame.locals);
598 indent(-1);
599 return null;
600 }
601
602 public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
603 if (frame instanceof StackMap_attribute.stack_map_frame) {
604 printHeader(frame, "offset = " + frame.offset_delta);
605 indent(+1);
606 } else {
607 printHeader(frame, "/* full_frame */");
608 indent(+1);
609 println("offset_delta = " + frame.offset_delta);
610 }
611 printMap("locals", frame.locals);
612 printMap("stack", frame.stack);
613 indent(-1);
614 return null;
615 }
616
617 void printHeader(StackMapTable_attribute.stack_map_frame frame, String extra) {
618 print("frame_type = " + frame.frame_type + " ");
619 println(extra);
620 }
621
622 void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
623 print(name + " = [");
624 for (int i = 0; i < map.length; i++) {
625 StackMapTable_attribute.verification_type_info info = map[i];
626 int tag = info.tag;
627 switch (tag) {
628 case StackMapTable_attribute.verification_type_info.ITEM_Object:
629 print(" ");
630 constantWriter.write(((StackMapTable_attribute.Object_variable_info) info).cpool_index);
631 break;
632 case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
633 print(" " + mapTypeName(tag));
634 print(" " + ((StackMapTable_attribute.Uninitialized_variable_info) info).offset);
635 break;
636 default:
637 print(" " + mapTypeName(tag));
638 }
639 print(i == (map.length - 1) ? " " : ",");
640 }
641 println("]");
642 }
643
644 String mapTypeName(int tag) {
645 switch (tag) {
646 case StackMapTable_attribute.verification_type_info.ITEM_Top:
647 return "top";
648
649 case StackMapTable_attribute.verification_type_info.ITEM_Integer:
650 return "int";
651
652 case StackMapTable_attribute.verification_type_info.ITEM_Float:
653 return "float";
654
655 case StackMapTable_attribute.verification_type_info.ITEM_Long:
656 return "long";
657
658 case StackMapTable_attribute.verification_type_info.ITEM_Double:
659 return "double";
660
661 case StackMapTable_attribute.verification_type_info.ITEM_Null:
662 return "null";
663
664 case StackMapTable_attribute.verification_type_info.ITEM_UninitializedThis:
665 return "this";
666
667 case StackMapTable_attribute.verification_type_info.ITEM_Object:
668 return "CP";
669
670 case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
671 return "uninitialized";
672
673 default:
674 report("unrecognized verification_type_info tag: " + tag);
675 return "[tag:" + tag + "]";
676 }
677 }
678 }
679
680 public Void visitSynthetic(Synthetic_attribute attr, Void ignore) {
681 println("Synthetic: true");
682 return null;
683 }
684
685 static String getJavaName(String name) {
686 return name.replace('/', '.');
687 }
688
689 String toHex(byte b, int w) {
690 return toHex(b & 0xff, w);
691 }
692
693 static String toHex(int i) {
694 return StringUtils.toUpperCase(Integer.toString(i, 16));
695 }
696
697 static String toHex(int i, int w) {
698 String s = StringUtils.toUpperCase(Integer.toHexString(i));
699 while (s.length() < w)
700 s = "0" + s;
701 return StringUtils.toUpperCase(s);
702 }
703
704 private AnnotationWriter annotationWriter;
705 private CodeWriter codeWriter;
706 private ConstantWriter constantWriter;
707 private Options options;
708
709 private ConstantPool constant_pool;
710 private Object owner;
711 }

mercurial