equal
deleted
inserted
replaced
118 } |
118 } |
119 |
119 |
120 public void write(ClassFile cf) { |
120 public void write(ClassFile cf) { |
121 setClassFile(cf); |
121 setClassFile(cf); |
122 |
122 |
123 if ((options.sysInfo || options.verbose) && !options.compat) { |
123 if (options.sysInfo || options.verbose) { |
124 if (uri != null) { |
124 if (uri != null) { |
125 if (uri.getScheme().equals("file")) |
125 if (uri.getScheme().equals("file")) |
126 println("Classfile " + uri.getPath()); |
126 println("Classfile " + uri.getPath()); |
127 else |
127 else |
128 println("Classfile " + uri); |
128 println("Classfile " + uri); |
150 Attribute sfa = cf.getAttribute(Attribute.SourceFile); |
150 Attribute sfa = cf.getAttribute(Attribute.SourceFile); |
151 if (sfa instanceof SourceFile_attribute) { |
151 if (sfa instanceof SourceFile_attribute) { |
152 println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\""); |
152 println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\""); |
153 } |
153 } |
154 |
154 |
155 if ((options.sysInfo || options.verbose) && !options.compat) { |
155 if (options.sysInfo || options.verbose) { |
156 indent(-1); |
156 indent(-1); |
157 } |
157 } |
158 |
158 |
159 String name = getJavaName(classFile); |
159 String name = getJavaName(classFile); |
160 AccessFlags flags = cf.access_flags; |
160 AccessFlags flags = cf.access_flags; |
203 println(); |
203 println(); |
204 indent(+1); |
204 indent(+1); |
205 attrWriter.write(cf, cf.attributes, constant_pool); |
205 attrWriter.write(cf, cf.attributes, constant_pool); |
206 println("minor version: " + cf.minor_version); |
206 println("minor version: " + cf.minor_version); |
207 println("major version: " + cf.major_version); |
207 println("major version: " + cf.major_version); |
208 if (!options.compat) |
208 writeList("flags: ", flags.getClassFlags(), "\n"); |
209 writeList("flags: ", flags.getClassFlags(), "\n"); |
|
210 indent(-1); |
209 indent(-1); |
211 constantWriter.writeConstantPool(); |
210 constantWriter.writeConstantPool(); |
212 } else { |
211 } else { |
213 print(" "); |
212 print(" "); |
214 } |
213 } |
370 print(getJavaFieldType(f.descriptor)); |
369 print(getJavaFieldType(f.descriptor)); |
371 } |
370 } |
372 } |
371 } |
373 print(" "); |
372 print(" "); |
374 print(getFieldName(f)); |
373 print(getFieldName(f)); |
375 if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents |
374 if (options.showConstants) { |
376 Attribute a = f.attributes.get(Attribute.ConstantValue); |
375 Attribute a = f.attributes.get(Attribute.ConstantValue); |
377 if (a instanceof ConstantValue_attribute) { |
376 if (a instanceof ConstantValue_attribute) { |
378 print(" = "); |
377 print(" = "); |
379 ConstantValue_attribute cv = (ConstantValue_attribute) a; |
378 ConstantValue_attribute cv = (ConstantValue_attribute) a; |
380 print(getConstantValue(f.descriptor, cv.constantvalue_index)); |
379 print(getConstantValue(f.descriptor, cv.constantvalue_index)); |
388 boolean showBlank = false; |
387 boolean showBlank = false; |
389 |
388 |
390 if (options.showDescriptors) |
389 if (options.showDescriptors) |
391 println("descriptor: " + getValue(f.descriptor)); |
390 println("descriptor: " + getValue(f.descriptor)); |
392 |
391 |
393 if (options.verbose && !options.compat) |
392 if (options.verbose) |
394 writeList("flags: ", flags.getFieldFlags(), "\n"); |
393 writeList("flags: ", flags.getFieldFlags(), "\n"); |
395 |
394 |
396 if (options.showAllAttrs) { |
395 if (options.showAllAttrs) { |
397 for (Attribute attr: f.attributes) |
396 for (Attribute attr: f.attributes) |
398 attrWriter.write(f, attr, constant_pool); |
397 attrWriter.write(f, attr, constant_pool); |
485 |
484 |
486 if (options.showDescriptors) { |
485 if (options.showDescriptors) { |
487 println("descriptor: " + getValue(m.descriptor)); |
486 println("descriptor: " + getValue(m.descriptor)); |
488 } |
487 } |
489 |
488 |
490 if (options.verbose && !options.compat) { |
489 if (options.verbose) { |
491 writeList("flags: ", flags.getMethodFlags(), "\n"); |
490 writeList("flags: ", flags.getMethodFlags(), "\n"); |
492 } |
491 } |
493 |
492 |
494 Code_attribute code = null; |
493 Code_attribute code = null; |
495 Attribute c_attr = m.attributes.get(Attribute.Code); |
494 Attribute c_attr = m.attributes.get(Attribute.Code); |
551 if (items != null && items.size() > 0) |
550 if (items != null && items.size() > 0) |
552 writeList(prefix, items, suffix); |
551 writeList(prefix, items, suffix); |
553 } |
552 } |
554 |
553 |
555 Signature_attribute getSignature(Attributes attributes) { |
554 Signature_attribute getSignature(Attributes attributes) { |
556 if (options.compat) // javap does not recognize recent attributes |
|
557 return null; |
|
558 return (Signature_attribute) attributes.get(Attribute.Signature); |
555 return (Signature_attribute) attributes.get(Attribute.Signature); |
559 } |
556 } |
560 |
557 |
561 String adjustVarargs(AccessFlags flags, String params) { |
558 String adjustVarargs(AccessFlags flags, String params) { |
562 if (flags.is(ACC_VARARGS) && !options.compat) { |
559 if (flags.is(ACC_VARARGS)) { |
563 int i = params.lastIndexOf("[]"); |
560 int i = params.lastIndexOf("[]"); |
564 if (i > 0) |
561 if (i > 0) |
565 return params.substring(0, i) + "..." + params.substring(i+2); |
562 return params.substring(0, i) + "..." + params.substring(i+2); |
566 } |
563 } |
567 |
564 |