Thu, 30 Jul 2009 09:18:55 -0700
4880672: javap does not output inner interfaces of an interface
Reviewed-by: mcimadamore
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.Field;
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.ModuleExportTable_attribute;
50 import com.sun.tools.classfile.ModuleMemberTable_attribute;
51 import com.sun.tools.classfile.Module_attribute;
52 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
53 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
54 import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
55 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
56 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
57 import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
58 import com.sun.tools.classfile.Signature_attribute;
59 import com.sun.tools.classfile.SourceDebugExtension_attribute;
60 import com.sun.tools.classfile.SourceFile_attribute;
61 import com.sun.tools.classfile.SourceID_attribute;
62 import com.sun.tools.classfile.StackMapTable_attribute;
63 import com.sun.tools.classfile.StackMap_attribute;
64 import com.sun.tools.classfile.Synthetic_attribute;
66 import static com.sun.tools.classfile.AccessFlags.*;
68 /*
69 * A writer for writing Attributes as text.
70 *
71 * <p><b>This is NOT part of any API supported by Sun Microsystems. If
72 * you write code that depends on this, you do so at your own risk.
73 * This code and its internal interfaces are subject to change or
74 * deletion without notice.</b>
75 */
76 public class AttributeWriter extends BasicWriter
77 implements Attribute.Visitor<Void,Void>
78 {
79 public static AttributeWriter instance(Context context) {
80 AttributeWriter instance = context.get(AttributeWriter.class);
81 if (instance == null)
82 instance = new AttributeWriter(context);
83 return instance;
84 }
86 protected AttributeWriter(Context context) {
87 super(context);
88 context.put(AttributeWriter.class, this);
89 annotationWriter = AnnotationWriter.instance(context);
90 codeWriter = CodeWriter.instance(context);
91 constantWriter = ConstantWriter.instance(context);
92 options = Options.instance(context);
93 }
95 public void write(Object owner, Attribute attr, ConstantPool constant_pool) {
96 if (attr != null) {
97 // null checks
98 owner.getClass();
99 constant_pool.getClass();
100 this.constant_pool = constant_pool;
101 this.owner = owner;
102 attr.accept(this, null);
103 }
104 }
106 public void write(Object owner, Attributes attrs, ConstantPool constant_pool) {
107 if (attrs != null) {
108 // null checks
109 owner.getClass();
110 constant_pool.getClass();
111 this.constant_pool = constant_pool;
112 this.owner = owner;
113 for (Attribute attr: attrs)
114 attr.accept(this, null);
115 }
116 }
118 public Void visitDefault(DefaultAttribute attr, Void ignore) {
119 byte[] data = attr.info;
120 int i = 0;
121 int j = 0;
122 print(" ");
123 try {
124 print(attr.getName(constant_pool));
125 } catch (ConstantPoolException e) {
126 report(e);
127 print("attribute name = #" + attr.attribute_name_index);
128 }
129 print(": ");
130 println("length = 0x" + toHex(attr.info.length));
132 print(" ");
134 while (i < data.length) {
135 print(toHex(data[i], 2));
137 j++;
138 if (j == 16) {
139 println();
140 print(" ");
141 j = 0;
142 } else {
143 print(" ");
144 }
145 i++;
146 }
147 println();
148 return null;
149 }
151 public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) {
152 println(" AnnotationDefault: ");
153 print(" default_value: ");
154 annotationWriter.write(attr.default_value);
155 return null;
156 }
158 public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) {
159 print(" CharacterRangeTable: ");
160 for (int i = 0; i < attr.character_range_table.length; i++) {
161 CharacterRangeTable_attribute.Entry e = attr.character_range_table[i];
162 print(" " + e.start_pc + ", " +
163 e.end_pc + ", " +
164 Integer.toHexString(e.character_range_start) + ", " +
165 Integer.toHexString(e.character_range_end) + ", " +
166 Integer.toHexString(e.flags) +
167 "\t// ");
168 print(e.start_pc + ", " +
169 e.end_pc + ", " +
170 (e.character_range_start >> 10) + ":" + (e.character_range_start & 0x3ff) + ", " +
171 (e.character_range_end >> 10) + ":" + (e.character_range_end & 0x3ff));
172 if ((e.flags & CharacterRangeTable_attribute.CRT_STATEMENT) != 0)
173 print(", statement");
174 if ((e.flags & CharacterRangeTable_attribute.CRT_BLOCK) != 0)
175 print(", block");
176 if ((e.flags & CharacterRangeTable_attribute.CRT_ASSIGNMENT) != 0)
177 print(", assignment");
178 if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_CONTROLLER) != 0)
179 print(", flow-controller");
180 if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_TARGET) != 0)
181 print(", flow-target");
182 if ((e.flags & CharacterRangeTable_attribute.CRT_INVOKE) != 0)
183 print(", invoke");
184 if ((e.flags & CharacterRangeTable_attribute.CRT_CREATE) != 0)
185 print(", create");
186 if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_TRUE) != 0)
187 print(", branch-true");
188 if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0)
189 print(", branch-false");
193 }
194 return null;
195 }
197 public Void visitCode(Code_attribute attr, Void ignore) {
198 codeWriter.write(attr, constant_pool);
199 println();
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 if (!options.compat) // BUG 6622232 javap gets whitespace confused
215 println();
216 return null;
217 }
219 public Void visitDeprecated(Deprecated_attribute attr, Void ignore) {
220 if (!(options.compat && owner instanceof Field)) // BUG 6622232 javap gets whitespace confused
221 print(" ");
222 println("Deprecated: true");
223 return null;
224 }
226 public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) {
227 print(" EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index
228 + "\t// " + getJavaClassName(attr));
229 if (attr.method_index != 0)
230 print("." + getMethodName(attr));
231 println();
232 return null;
233 }
235 private String getJavaClassName(EnclosingMethod_attribute a) {
236 try {
237 return getJavaName(a.getClassName(constant_pool));
238 } catch (ConstantPoolException e) {
239 return report(e);
240 }
241 }
243 private String getMethodName(EnclosingMethod_attribute a) {
244 try {
245 return a.getMethodName(constant_pool);
246 } catch (ConstantPoolException e) {
247 return report(e);
248 }
249 }
251 public Void visitExceptions(Exceptions_attribute attr, Void ignore) {
252 println(" Exceptions: ");
253 print(" throws ");
254 for (int i = 0; i < attr.number_of_exceptions; i++) {
255 if (i > 0)
256 print(", ");
257 print(getJavaException(attr, i));
258 }
259 if (!options.compat) // BUG 6622232 javap gets whitespace confused
260 println();
261 return null;
262 }
264 private String getJavaException(Exceptions_attribute attr, int index) {
265 try {
266 return getJavaName(attr.getException(index, constant_pool));
267 } catch (ConstantPoolException e) {
268 return report(e);
269 }
270 }
272 public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
273 boolean first = true;
274 if (options.compat) {
275 writeInnerClassHeader();
276 first = false;
277 }
278 for (int i = 0 ; i < attr.classes.length; i++) {
279 InnerClasses_attribute.Info info = attr.classes[i];
280 //access
281 AccessFlags access_flags = info.inner_class_access_flags;
282 if (options.compat) {
283 // BUG 6622215: javap ignores certain relevant access flags
284 access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
285 // BUG 6622232: javap gets whitespace confused
286 print(" ");
287 }
288 if (options.checkAccess(access_flags)) {
289 if (first) {
290 writeInnerClassHeader();
291 first = false;
292 }
293 if (!options.compat) // BUG 6622232: javap gets whitespace confused
294 print(" ");
295 for (String name: access_flags.getInnerClassModifiers())
296 print(name + " ");
297 if (info.inner_name_index!=0) {
298 print("#" + info.inner_name_index + "= ");
299 }
300 print("#" + info.inner_class_info_index);
301 if (info.outer_class_info_index != 0) {
302 print(" of #" + info.outer_class_info_index);
303 }
304 print("; //");
305 if (info.inner_name_index != 0) {
306 print(getInnerName(constant_pool, info) + "=");
307 }
308 constantWriter.write(info.inner_class_info_index);
309 if (info.outer_class_info_index != 0) {
310 print(" of ");
311 constantWriter.write(info.outer_class_info_index);
312 }
313 println();
314 }
315 }
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 print(" ");
329 if (options.compat) // BUG 6622216: javap names some attributes incorrectly
330 print("InnerClass");
331 else
332 print("InnerClasses");
333 println(": ");
334 }
336 public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) {
337 println(" LineNumberTable: ");
338 for (LineNumberTable_attribute.Entry entry: attr.line_number_table) {
339 println(" line " + entry.line_number + ": " + entry.start_pc);
340 }
341 return null;
342 }
344 public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) {
345 println(" LocalVariableTable: ");
346 println(" Start Length Slot Name Signature");
348 for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
349 Formatter formatter = new Formatter();
350 println(formatter.format("%8d %7d %5d %5s %s",
351 entry.start_pc, entry.length, entry.index,
352 constantWriter.stringValue(entry.name_index),
353 constantWriter.stringValue(entry.descriptor_index)));
354 }
355 return null;
356 }
358 public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) {
359 println(" LocalVariableTypeTable: ");
360 println(" Start Length Slot Name Signature");
362 for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) {
363 Formatter formatter = new Formatter();
364 println(formatter.format("%8d %7d %5d %5s %s",
365 entry.start_pc, entry.length, entry.index,
366 constantWriter.stringValue(entry.name_index),
367 constantWriter.stringValue(entry.signature_index)));
368 }
369 return null;
370 }
372 public Void visitModule(Module_attribute attr, Void ignore) {
373 println(" Module: #" + attr.module_name + "\t// " + getModuleName(attr));
374 return null;
375 }
377 String getModuleName(Module_attribute attr) {
378 try {
379 return attr.getModuleName(constant_pool);
380 } catch (ConstantPoolException e) {
381 return report(e);
382 }
383 }
385 public Void visitModuleExportTable(ModuleExportTable_attribute attr, Void ignore) {
386 println(" ModuleExportTable:");
387 println(" Types: (" + attr.export_type_table.length + ")");
388 for (int i = 0; i < attr.export_type_table.length; i++) {
389 println(" #" + attr.export_type_table[i] + "\t// " + getExportTypeName(attr, i));
390 }
391 return null;
392 }
394 String getExportTypeName(ModuleExportTable_attribute attr, int index) {
395 try {
396 return attr.getExportTypeName(index, constant_pool);
397 } catch (ConstantPoolException e) {
398 return report(e);
399 }
400 }
402 public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, Void ignore) {
403 println(" ModuleMemberTable:");
404 println(" Packages: (" + attr.package_member_table.length + ")");
405 for (int i = 0; i < attr.package_member_table.length; i++) {
406 println(" #" + attr.package_member_table[i] + "\t// " + getPackageMemberName(attr, i));
407 }
408 return null;
409 }
411 String getPackageMemberName(ModuleMemberTable_attribute attr, int index) {
412 try {
413 return attr.getPackageMemberName(index, constant_pool);
414 } catch (ConstantPoolException e) {
415 return report(e);
416 }
417 }
419 public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
420 println(" RuntimeVisibleAnnotations: ");
421 for (int i = 0; i < attr.annotations.length; i++) {
422 print(" " + i + ": ");
423 annotationWriter.write(attr.annotations[i]);
424 println();
425 }
426 return null;
427 }
429 public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) {
430 println(" RuntimeInvisibleAnnotations: ");
431 for (int i = 0; i < attr.annotations.length; i++) {
432 print(" " + i + ": ");
433 annotationWriter.write(attr.annotations[i]);
434 println();
435 }
436 return null;
437 }
439 public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, Void ignore) {
440 println(" RuntimeVisibleTypeAnnotations: ");
441 for (int i = 0; i < attr.annotations.length; i++) {
442 print(" " + i + ": ");
443 annotationWriter.write(attr.annotations[i]);
444 println();
445 }
446 return null;
447 }
449 public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, Void ignore) {
450 println(" RuntimeInvisibleTypeAnnotations: ");
451 for (int i = 0; i < attr.annotations.length; i++) {
452 print(" " + i + ": ");
453 annotationWriter.write(attr.annotations[i]);
454 println();
455 }
456 return null;
457 }
459 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
460 println(" RuntimeVisibleParameterAnnotations: ");
461 for (int param = 0; param < attr.parameter_annotations.length; param++) {
462 println(" parameter " + param + ": ");
463 for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
464 print(" " + i + ": ");
465 annotationWriter.write(attr.parameter_annotations[param][i]);
466 println();
467 }
468 }
469 return null;
470 }
472 public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) {
473 println(" RuntimeInvisibleParameterAnnotations: ");
474 for (int param = 0; param < attr.parameter_annotations.length; param++) {
475 println(" " + param + ": ");
476 for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
477 print(" " + i + ": ");
478 annotationWriter.write(attr.parameter_annotations[param][i]);
479 println();
480 }
481 }
482 return null;
483 }
485 public Void visitSignature(Signature_attribute attr, Void ignore) {
486 println(" Signature: #" + attr.signature_index + "\t// " + getSignature(attr));
487 return null;
488 }
490 String getSignature(Signature_attribute info) {
491 try {
492 return info.getSignature(constant_pool);
493 } catch (ConstantPoolException e) {
494 return report(e);
495 }
496 }
498 public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
499 println(" SourceDebugExtension: " + attr.getValue());
500 return null;
501 }
503 public Void visitSourceFile(SourceFile_attribute attr, Void ignore) {
504 println(" SourceFile: \"" + getSourceFile(attr) + "\"");
505 return null;
506 }
508 private String getSourceFile(SourceFile_attribute attr) {
509 try {
510 return attr.getSourceFile(constant_pool);
511 } catch (ConstantPoolException e) {
512 return report(e);
513 }
514 }
516 public Void visitSourceID(SourceID_attribute attr, Void ignore) {
517 constantWriter.write(attr.sourceID_index);
518 return null;
519 }
521 public Void visitStackMap(StackMap_attribute attr, Void ignore) {
522 println(" StackMap: number_of_entries = " + attr.number_of_entries);
524 StackMapTableWriter w = new StackMapTableWriter();
525 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
526 w.write(entry);
527 }
528 println();
529 return null;
530 }
532 public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) {
533 println(" StackMapTable: number_of_entries = " + attr.number_of_entries);
535 StackMapTableWriter w = new StackMapTableWriter();
536 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
537 w.write(entry);
538 }
539 println();
540 return null;
541 }
543 class StackMapTableWriter // also handles CLDC StackMap attributes
544 implements StackMapTable_attribute.stack_map_frame.Visitor<Void,Void> {
545 public void write(StackMapTable_attribute.stack_map_frame frame) {
546 frame.accept(this, null);
547 }
549 public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
550 printHeader(frame);
551 println(" /* same */");
552 return null;
553 }
555 public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
556 printHeader(frame);
557 println(" /* same_locals_1_stack_item */");
558 printMap("stack", frame.stack);
559 return null;
560 }
562 public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
563 printHeader(frame);
564 println(" /* same_locals_1_stack_item_frame_extended */");
565 println(" offset_delta = " + frame.offset_delta);
566 printMap("stack", frame.stack);
567 return null;
568 }
570 public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
571 printHeader(frame);
572 println(" /* chop */");
573 println(" offset_delta = " + frame.offset_delta);
574 return null;
575 }
577 public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
578 printHeader(frame);
579 println(" /* same_frame_extended */");
580 println(" offset_delta = " + frame.offset_delta);
581 return null;
582 }
584 public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
585 printHeader(frame);
586 println(" /* append */");
587 println(" offset_delta = " + frame.offset_delta);
588 printMap("locals", frame.locals);
589 return null;
590 }
592 public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
593 printHeader(frame);
594 if (frame instanceof StackMap_attribute.stack_map_frame) {
595 println(" offset = " + frame.offset_delta);
596 } else {
597 println(" /* full_frame */");
598 println(" offset_delta = " + frame.offset_delta);
599 }
600 printMap("locals", frame.locals);
601 printMap("stack", frame.stack);
602 return null;
603 }
605 void printHeader(StackMapTable_attribute.stack_map_frame frame) {
606 print(" frame_type = " + frame.frame_type);
607 }
609 void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
610 print(" " + name + " = [");
611 for (int i = 0; i < map.length; i++) {
612 StackMapTable_attribute.verification_type_info info = map[i];
613 int tag = info.tag;
614 switch (tag) {
615 case StackMapTable_attribute.verification_type_info.ITEM_Object:
616 print(" ");
617 constantWriter.write(((StackMapTable_attribute.Object_variable_info) info).cpool_index);
618 break;
619 case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
620 print(" " + mapTypeName(tag));
621 print(" " + ((StackMapTable_attribute.Uninitialized_variable_info) info).offset);
622 break;
623 default:
624 print(" " + mapTypeName(tag));
625 }
626 print(i == (map.length - 1) ? " " : ",");
627 }
628 println("]");
629 }
631 String mapTypeName(int tag) {
632 switch (tag) {
633 case StackMapTable_attribute.verification_type_info.ITEM_Top:
634 return "top";
636 case StackMapTable_attribute.verification_type_info.ITEM_Integer:
637 return "int";
639 case StackMapTable_attribute.verification_type_info.ITEM_Float:
640 return "float";
642 case StackMapTable_attribute.verification_type_info.ITEM_Long:
643 return "long";
645 case StackMapTable_attribute.verification_type_info.ITEM_Double:
646 return "double";
648 case StackMapTable_attribute.verification_type_info.ITEM_Null:
649 return "null";
651 case StackMapTable_attribute.verification_type_info.ITEM_UninitializedThis:
652 return "this";
654 case StackMapTable_attribute.verification_type_info.ITEM_Object:
655 return "CP";
657 case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
658 return "uninitialized";
660 default:
661 report("unrecognized verification_type_info tag: " + tag);
662 return "[tag:" + tag + "]";
663 }
664 }
665 }
667 public Void visitSynthetic(Synthetic_attribute attr, Void ignore) {
668 println("Synthetic: true");
669 return null;
670 }
672 static String getJavaName(String name) {
673 return name.replace('/', '.');
674 }
676 String toHex(byte b, int w) {
677 if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
678 return toHex((int) b, w);
679 else
680 return toHex(b & 0xff, w);
681 }
683 static String toHex(int i) {
684 return Integer.toString(i, 16).toUpperCase();
685 }
687 static String toHex(int i, int w) {
688 String s = Integer.toHexString(i).toUpperCase();
689 while (s.length() < w)
690 s = "0" + s;
691 return s.toUpperCase();
692 }
694 private AnnotationWriter annotationWriter;
695 private CodeWriter codeWriter;
696 private ConstantWriter constantWriter;
697 private Options options;
699 private ConstantPool constant_pool;
700 private Object owner;
701 }