Wed, 23 Sep 2009 19:15:04 -0700
6572945: javah should be written as an annotation processor, not a doclet
Reviewed-by: darcy
1 /*
2 * Copyright 2007-2008 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
26 package com.sun.tools.javap;
28 import java.util.Formatter;
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.CharacterRangeTable_attribute;
35 import com.sun.tools.classfile.Code_attribute;
36 import com.sun.tools.classfile.CompilationID_attribute;
37 import com.sun.tools.classfile.ConstantPool;
38 import com.sun.tools.classfile.ConstantPoolException;
39 import com.sun.tools.classfile.ConstantValue_attribute;
40 import com.sun.tools.classfile.DefaultAttribute;
41 import com.sun.tools.classfile.Deprecated_attribute;
42 import com.sun.tools.classfile.EnclosingMethod_attribute;
43 import com.sun.tools.classfile.Exceptions_attribute;
44 import com.sun.tools.classfile.InnerClasses_attribute;
45 import com.sun.tools.classfile.LineNumberTable_attribute;
46 import com.sun.tools.classfile.LocalVariableTable_attribute;
47 import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
48 import com.sun.tools.classfile.ModuleExportTable_attribute;
49 import com.sun.tools.classfile.ModuleMemberTable_attribute;
50 import com.sun.tools.classfile.Module_attribute;
51 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
52 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
53 import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
54 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
55 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
56 import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
57 import com.sun.tools.classfile.Signature_attribute;
58 import com.sun.tools.classfile.SourceDebugExtension_attribute;
59 import com.sun.tools.classfile.SourceFile_attribute;
60 import com.sun.tools.classfile.SourceID_attribute;
61 import com.sun.tools.classfile.StackMapTable_attribute;
62 import com.sun.tools.classfile.StackMap_attribute;
63 import com.sun.tools.classfile.Synthetic_attribute;
65 import static com.sun.tools.classfile.AccessFlags.*;
67 /*
68 * A writer for writing Attributes as text.
69 *
70 * <p><b>This is NOT part of any API supported by Sun Microsystems. If
71 * 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 }
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 }
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 }
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 }
117 public Void visitDefault(DefaultAttribute attr, Void ignore) {
118 byte[] data = attr.info;
119 int i = 0;
120 int j = 0;
121 print(" ");
122 try {
123 print(attr.getName(constant_pool));
124 } catch (ConstantPoolException e) {
125 report(e);
126 print("attribute name = #" + attr.attribute_name_index);
127 }
128 print(": ");
129 println("length = 0x" + toHex(attr.info.length));
131 print(" ");
133 while (i < data.length) {
134 print(toHex(data[i], 2));
136 j++;
137 if (j == 16) {
138 println();
139 print(" ");
140 j = 0;
141 } else {
142 print(" ");
143 }
144 i++;
145 }
146 println();
147 return null;
148 }
150 public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) {
151 println("AnnotationDefault:");
152 indent(+1);
153 print("default_value: ");
154 annotationWriter.write(attr.default_value);
155 indent(-1);
156 return null;
157 }
159 public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) {
160 println("CharacterRangeTable:");
161 indent(+1);
162 for (int i = 0; i < attr.character_range_table.length; i++) {
163 CharacterRangeTable_attribute.Entry e = attr.character_range_table[i];
164 print(" " + e.start_pc + ", " +
165 e.end_pc + ", " +
166 Integer.toHexString(e.character_range_start) + ", " +
167 Integer.toHexString(e.character_range_end) + ", " +
168 Integer.toHexString(e.flags));
169 tab();
170 print("// ");
171 print(e.start_pc + ", " +
172 e.end_pc + ", " +
173 (e.character_range_start >> 10) + ":" + (e.character_range_start & 0x3ff) + ", " +
174 (e.character_range_end >> 10) + ":" + (e.character_range_end & 0x3ff));
175 if ((e.flags & CharacterRangeTable_attribute.CRT_STATEMENT) != 0)
176 print(", statement");
177 if ((e.flags & CharacterRangeTable_attribute.CRT_BLOCK) != 0)
178 print(", block");
179 if ((e.flags & CharacterRangeTable_attribute.CRT_ASSIGNMENT) != 0)
180 print(", assignment");
181 if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_CONTROLLER) != 0)
182 print(", flow-controller");
183 if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_TARGET) != 0)
184 print(", flow-target");
185 if ((e.flags & CharacterRangeTable_attribute.CRT_INVOKE) != 0)
186 print(", invoke");
187 if ((e.flags & CharacterRangeTable_attribute.CRT_CREATE) != 0)
188 print(", create");
189 if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_TRUE) != 0)
190 print(", branch-true");
191 if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0)
192 print(", branch-false");
193 }
194 indent(-1);
195 return null;
196 }
198 public Void visitCode(Code_attribute attr, Void ignore) {
199 codeWriter.write(attr, constant_pool);
200 return null;
201 }
203 public Void visitCompilationID(CompilationID_attribute attr, Void ignore) {
204 constantWriter.write(attr.compilationID_index);
205 return null;
206 }
208 public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
209 if (options.compat) // BUG 6622216 javap names some attributes incorrectly
210 print("Constant value: ");
211 else
212 print("ConstantValue: ");
213 constantWriter.write(attr.constantvalue_index);
214 println();
215 return null;
216 }
218 public Void visitDeprecated(Deprecated_attribute attr, Void ignore) {
219 println("Deprecated: true");
220 return null;
221 }
223 public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) {
224 print("EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index);
225 tab();
226 print("// " + getJavaClassName(attr));
227 if (attr.method_index != 0)
228 print("." + getMethodName(attr));
229 println();
230 return null;
231 }
233 private String getJavaClassName(EnclosingMethod_attribute a) {
234 try {
235 return getJavaName(a.getClassName(constant_pool));
236 } catch (ConstantPoolException e) {
237 return report(e);
238 }
239 }
241 private String getMethodName(EnclosingMethod_attribute a) {
242 try {
243 return a.getMethodName(constant_pool);
244 } catch (ConstantPoolException e) {
245 return report(e);
246 }
247 }
249 public Void visitExceptions(Exceptions_attribute attr, Void ignore) {
250 println("Exceptions:");
251 indent(+1);
252 print("throws ");
253 for (int i = 0; i < attr.number_of_exceptions; i++) {
254 if (i > 0)
255 print(", ");
256 print(getJavaException(attr, i));
257 }
258 println();
259 indent(-1);
260 return null;
261 }
263 private String getJavaException(Exceptions_attribute attr, int index) {
264 try {
265 return getJavaName(attr.getException(index, constant_pool));
266 } catch (ConstantPoolException e) {
267 return report(e);
268 }
269 }
271 public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
272 boolean first = true;
273 if (options.compat) {
274 writeInnerClassHeader();
275 first = false;
276 }
277 for (int i = 0 ; i < attr.classes.length; i++) {
278 InnerClasses_attribute.Info info = attr.classes[i];
279 //access
280 AccessFlags access_flags = info.inner_class_access_flags;
281 if (options.compat) {
282 // BUG 6622215: javap ignores certain relevant access flags
283 access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
284 // BUG 6622232: javap gets whitespace confused
285 print(" ");
286 }
287 if (options.checkAccess(access_flags)) {
288 if (first) {
289 writeInnerClassHeader();
290 first = false;
291 }
292 print(" ");
293 for (String name: access_flags.getInnerClassModifiers())
294 print(name + " ");
295 if (info.inner_name_index!=0) {
296 print("#" + info.inner_name_index + "= ");
297 }
298 print("#" + info.inner_class_info_index);
299 if (info.outer_class_info_index != 0) {
300 print(" of #" + info.outer_class_info_index);
301 }
302 print("; //");
303 if (info.inner_name_index != 0) {
304 print(getInnerName(constant_pool, info) + "=");
305 }
306 constantWriter.write(info.inner_class_info_index);
307 if (info.outer_class_info_index != 0) {
308 print(" of ");
309 constantWriter.write(info.outer_class_info_index);
310 }
311 println();
312 }
313 }
314 if (!first)
315 indent(-1);
316 return null;
317 }
319 String getInnerName(ConstantPool constant_pool, InnerClasses_attribute.Info info) {
320 try {
321 return info.getInnerName(constant_pool);
322 } catch (ConstantPoolException e) {
323 return report(e);
324 }
325 }
327 private void writeInnerClassHeader() {
328 if (options.compat) // BUG 6622216: javap names some attributes incorrectly
329 print("InnerClass");
330 else
331 print("InnerClasses");
332 println(":");
333 indent(+1);
334 }
336 public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) {
337 println("LineNumberTable:");
338 indent(+1);
339 for (LineNumberTable_attribute.Entry entry: attr.line_number_table) {
340 println("line " + entry.line_number + ": " + entry.start_pc);
341 }
342 indent(-1);
343 return null;
344 }
346 public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) {
347 println("LocalVariableTable:");
348 indent(+1);
349 println("Start Length Slot Name Signature");
350 for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
351 Formatter formatter = new Formatter();
352 println(formatter.format("%8d %7d %5d %5s %s",
353 entry.start_pc, entry.length, entry.index,
354 constantWriter.stringValue(entry.name_index),
355 constantWriter.stringValue(entry.descriptor_index)));
356 }
357 indent(-1);
358 return null;
359 }
361 public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) {
362 println("LocalVariableTypeTable:");
363 indent(+1);
364 println("Start Length Slot Name Signature");
365 for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) {
366 println(String.format("%5d %7d %5d %5s %s",
367 entry.start_pc, entry.length, entry.index,
368 constantWriter.stringValue(entry.name_index),
369 constantWriter.stringValue(entry.signature_index)));
370 }
371 indent(-1);
372 return null;
373 }
375 public Void visitModule(Module_attribute attr, Void ignore) {
376 print("Module: #" + attr.module_name);
377 tab();
378 println("// " + getModuleName(attr));
379 return null;
380 }
382 String getModuleName(Module_attribute attr) {
383 try {
384 return attr.getModuleName(constant_pool);
385 } catch (ConstantPoolException e) {
386 return report(e);
387 }
388 }
390 public Void visitModuleExportTable(ModuleExportTable_attribute attr, Void ignore) {
391 println("ModuleExportTable:");
392 indent(+1);
393 println("Types: (" + attr.export_type_table.length + ")");
394 for (int i = 0; i < attr.export_type_table.length; i++) {
395 print("#" + attr.export_type_table[i]);
396 tab();
397 println("// " + getExportTypeName(attr, i));
398 }
399 indent(-1);
400 return null;
401 }
403 String getExportTypeName(ModuleExportTable_attribute attr, int index) {
404 try {
405 return attr.getExportTypeName(index, constant_pool);
406 } catch (ConstantPoolException e) {
407 return report(e);
408 }
409 }
411 public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, Void ignore) {
412 println("ModuleMemberTable:");
413 indent(+1);
414 println("Packages: (" + attr.package_member_table.length + ")");
415 for (int i = 0; i < attr.package_member_table.length; i++) {
416 print("#" + attr.package_member_table[i]);
417 tab();
418 println("// " + getPackageMemberName(attr, i));
419 }
420 indent(-1);
421 return null;
422 }
424 String getPackageMemberName(ModuleMemberTable_attribute attr, int index) {
425 try {
426 return attr.getPackageMemberName(index, constant_pool);
427 } catch (ConstantPoolException e) {
428 return report(e);
429 }
430 }
432 public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
433 println("RuntimeVisibleAnnotations:");
434 indent(+1);
435 for (int i = 0; i < attr.annotations.length; i++) {
436 print(i + ": ");
437 annotationWriter.write(attr.annotations[i]);
438 println();
439 }
440 indent(-1);
441 return null;
442 }
444 public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) {
445 println("RuntimeInvisibleAnnotations:");
446 indent(+1);
447 for (int i = 0; i < attr.annotations.length; i++) {
448 print(i + ": ");
449 annotationWriter.write(attr.annotations[i]);
450 println();
451 }
452 indent(-1);
453 return null;
454 }
456 public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, Void ignore) {
457 println("RuntimeVisibleTypeAnnotations:");
458 indent(+1);
459 for (int i = 0; i < attr.annotations.length; i++) {
460 print(i + ": ");
461 annotationWriter.write(attr.annotations[i]);
462 println();
463 }
464 indent(-1);
465 return null;
466 }
468 public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, Void ignore) {
469 println("RuntimeInvisibleTypeAnnotations:");
470 indent(+1);
471 for (int i = 0; i < attr.annotations.length; i++) {
472 print(i + ": ");
473 annotationWriter.write(attr.annotations[i]);
474 println();
475 }
476 indent(-1);
477 return null;
478 }
480 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
481 println("RuntimeVisibleParameterAnnotations:");
482 indent(+1);
483 for (int param = 0; param < attr.parameter_annotations.length; param++) {
484 println("parameter " + param + ": ");
485 indent(+1);
486 for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
487 print(i + ": ");
488 annotationWriter.write(attr.parameter_annotations[param][i]);
489 println();
490 }
491 indent(-1);
492 }
493 indent(-1);
494 return null;
495 }
497 public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) {
498 println("RuntimeInvisibleParameterAnnotations:");
499 indent(+1);
500 for (int param = 0; param < attr.parameter_annotations.length; param++) {
501 println(param + ": ");
502 indent(+1);
503 for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
504 print(i + ": ");
505 annotationWriter.write(attr.parameter_annotations[param][i]);
506 println();
507 }
508 indent(-1);
509 }
510 indent(-1);
511 return null;
512 }
514 public Void visitSignature(Signature_attribute attr, Void ignore) {
515 print("Signature: #" + attr.signature_index);
516 tab();
517 println("// " + getSignature(attr));
518 return null;
519 }
521 String getSignature(Signature_attribute info) {
522 try {
523 return info.getSignature(constant_pool);
524 } catch (ConstantPoolException e) {
525 return report(e);
526 }
527 }
529 public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
530 println("SourceDebugExtension: " + attr.getValue());
531 return null;
532 }
534 public Void visitSourceFile(SourceFile_attribute attr, Void ignore) {
535 println("SourceFile: \"" + getSourceFile(attr) + "\"");
536 return null;
537 }
539 private String getSourceFile(SourceFile_attribute attr) {
540 try {
541 return attr.getSourceFile(constant_pool);
542 } catch (ConstantPoolException e) {
543 return report(e);
544 }
545 }
547 public Void visitSourceID(SourceID_attribute attr, Void ignore) {
548 constantWriter.write(attr.sourceID_index);
549 return null;
550 }
552 public Void visitStackMap(StackMap_attribute attr, Void ignore) {
553 println("StackMap: number_of_entries = " + attr.number_of_entries);
554 indent(+1);
555 StackMapTableWriter w = new StackMapTableWriter();
556 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
557 w.write(entry);
558 }
559 println();
560 indent(-1);
561 return null;
562 }
564 public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) {
565 println("StackMapTable: number_of_entries = " + attr.number_of_entries);
566 indent(+1);
567 StackMapTableWriter w = new StackMapTableWriter();
568 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
569 w.write(entry);
570 }
571 println();
572 indent(-1);
573 return null;
574 }
576 class StackMapTableWriter // also handles CLDC StackMap attributes
577 implements StackMapTable_attribute.stack_map_frame.Visitor<Void,Void> {
578 public void write(StackMapTable_attribute.stack_map_frame frame) {
579 frame.accept(this, null);
580 }
582 public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
583 printHeader(frame);
584 println(" /* same */");
585 return null;
586 }
588 public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
589 printHeader(frame);
590 println(" /* same_locals_1_stack_item */");
591 indent(+1);
592 printMap("stack", frame.stack);
593 indent(-1);
594 return null;
595 }
597 public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
598 printHeader(frame);
599 println(" /* same_locals_1_stack_item_frame_extended */");
600 indent(+1);
601 println("offset_delta = " + frame.offset_delta);
602 printMap("stack", frame.stack);
603 indent(-1);
604 return null;
605 }
607 public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
608 printHeader(frame);
609 println(" /* chop */");
610 indent(+1);
611 println("offset_delta = " + frame.offset_delta);
612 indent(-1);
613 return null;
614 }
616 public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
617 printHeader(frame);
618 println(" /* same_frame_extended */");
619 indent(+1);
620 println("offset_delta = " + frame.offset_delta);
621 indent(-1);
622 return null;
623 }
625 public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
626 printHeader(frame);
627 println(" /* append */");
628 println(" offset_delta = " + frame.offset_delta);
629 printMap("locals", frame.locals);
630 return null;
631 }
633 public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
634 printHeader(frame);
635 if (frame instanceof StackMap_attribute.stack_map_frame) {
636 indent(+1);
637 println(" offset = " + frame.offset_delta);
638 } else {
639 println(" /* full_frame */");
640 indent(+1);
641 println("offset_delta = " + frame.offset_delta);
642 }
643 printMap("locals", frame.locals);
644 printMap("stack", frame.stack);
645 indent(-1);
646 return null;
647 }
649 void printHeader(StackMapTable_attribute.stack_map_frame frame) {
650 print(" frame_type = " + frame.frame_type);
651 }
653 void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
654 print(name + " = [");
655 for (int i = 0; i < map.length; i++) {
656 StackMapTable_attribute.verification_type_info info = map[i];
657 int tag = info.tag;
658 switch (tag) {
659 case StackMapTable_attribute.verification_type_info.ITEM_Object:
660 print(" ");
661 constantWriter.write(((StackMapTable_attribute.Object_variable_info) info).cpool_index);
662 break;
663 case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
664 print(" " + mapTypeName(tag));
665 print(" " + ((StackMapTable_attribute.Uninitialized_variable_info) info).offset);
666 break;
667 default:
668 print(" " + mapTypeName(tag));
669 }
670 print(i == (map.length - 1) ? " " : ",");
671 }
672 println("]");
673 }
675 String mapTypeName(int tag) {
676 switch (tag) {
677 case StackMapTable_attribute.verification_type_info.ITEM_Top:
678 return "top";
680 case StackMapTable_attribute.verification_type_info.ITEM_Integer:
681 return "int";
683 case StackMapTable_attribute.verification_type_info.ITEM_Float:
684 return "float";
686 case StackMapTable_attribute.verification_type_info.ITEM_Long:
687 return "long";
689 case StackMapTable_attribute.verification_type_info.ITEM_Double:
690 return "double";
692 case StackMapTable_attribute.verification_type_info.ITEM_Null:
693 return "null";
695 case StackMapTable_attribute.verification_type_info.ITEM_UninitializedThis:
696 return "this";
698 case StackMapTable_attribute.verification_type_info.ITEM_Object:
699 return "CP";
701 case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
702 return "uninitialized";
704 default:
705 report("unrecognized verification_type_info tag: " + tag);
706 return "[tag:" + tag + "]";
707 }
708 }
709 }
711 public Void visitSynthetic(Synthetic_attribute attr, Void ignore) {
712 println("Synthetic: true");
713 return null;
714 }
716 static String getJavaName(String name) {
717 return name.replace('/', '.');
718 }
720 String toHex(byte b, int w) {
721 if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
722 return toHex((int) b, w);
723 else
724 return toHex(b & 0xff, w);
725 }
727 static String toHex(int i) {
728 return Integer.toString(i, 16).toUpperCase();
729 }
731 static String toHex(int i, int w) {
732 String s = Integer.toHexString(i).toUpperCase();
733 while (s.length() < w)
734 s = "0" + s;
735 return s.toUpperCase();
736 }
738 private AnnotationWriter annotationWriter;
739 private CodeWriter codeWriter;
740 private ConstantWriter constantWriter;
741 private Options options;
743 private ConstantPool constant_pool;
744 private Object owner;
745 }