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