mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
6867671: javap whitespace formatting issues
Reviewed-by: mcimadamore
This commit is contained in:
parent
2437247a8d
commit
22c0a5cddf
7 changed files with 297 additions and 166 deletions
|
@ -120,6 +120,7 @@ public class ClassWriter extends BasicWriter {
|
|||
else
|
||||
println("Classfile " + uri);
|
||||
}
|
||||
indent(+1);
|
||||
if (lastModified != -1) {
|
||||
Date lm = new Date(lastModified);
|
||||
DateFormat df = DateFormat.getDateInstance();
|
||||
|
@ -144,6 +145,10 @@ public class ClassWriter extends BasicWriter {
|
|||
println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
|
||||
}
|
||||
|
||||
if ((options.sysInfo || options.verbose) && !options.compat) {
|
||||
indent(-1);
|
||||
}
|
||||
|
||||
String name = getJavaName(classFile);
|
||||
AccessFlags flags = cf.access_flags;
|
||||
|
||||
|
@ -186,23 +191,24 @@ public class ClassWriter extends BasicWriter {
|
|||
|
||||
if (options.verbose) {
|
||||
println();
|
||||
indent(+1);
|
||||
attrWriter.write(cf, cf.attributes, constant_pool);
|
||||
println(" minor version: " + cf.minor_version);
|
||||
println(" major version: " + cf.major_version);
|
||||
println("minor version: " + cf.minor_version);
|
||||
println("major version: " + cf.major_version);
|
||||
if (!options.compat)
|
||||
writeList(" flags: ", flags.getClassFlags(), NEWLINE);
|
||||
writeList("flags: ", flags.getClassFlags(), NEWLINE);
|
||||
indent(-1);
|
||||
constantWriter.writeConstantPool();
|
||||
println();
|
||||
} else {
|
||||
if (!options.compat)
|
||||
print(" ");
|
||||
print(" ");
|
||||
}
|
||||
|
||||
println("{");
|
||||
indent(+1);
|
||||
writeFields();
|
||||
writeMethods();
|
||||
indent(-1);
|
||||
println("}");
|
||||
println();
|
||||
}
|
||||
|
||||
protected void writeFields() {
|
||||
|
@ -215,14 +221,6 @@ public class ClassWriter extends BasicWriter {
|
|||
if (!options.checkAccess(f.access_flags))
|
||||
return;
|
||||
|
||||
if (!(options.showLineAndLocalVariableTables
|
||||
|| options.showDisassembled
|
||||
|| options.verbose
|
||||
|| options.showInternalSignatures
|
||||
|| options.showAllAttrs)) {
|
||||
print(" ");
|
||||
}
|
||||
|
||||
AccessFlags flags = f.access_flags;
|
||||
writeModifiers(flags.getFieldModifiers());
|
||||
Signature_attribute sigAttr = getSignature(f.attributes);
|
||||
|
@ -251,11 +249,13 @@ public class ClassWriter extends BasicWriter {
|
|||
print(";");
|
||||
println();
|
||||
|
||||
indent(+1);
|
||||
|
||||
if (options.showInternalSignatures)
|
||||
println(" Signature: " + getValue(f.descriptor));
|
||||
println("Signature: " + getValue(f.descriptor));
|
||||
|
||||
if (options.verbose && !options.compat)
|
||||
writeList(" flags: ", flags.getFieldFlags(), NEWLINE);
|
||||
writeList("flags: ", flags.getFieldFlags(), NEWLINE);
|
||||
|
||||
if (options.showAllAttrs) {
|
||||
for (Attribute attr: f.attributes)
|
||||
|
@ -263,6 +263,8 @@ public class ClassWriter extends BasicWriter {
|
|||
println();
|
||||
}
|
||||
|
||||
indent(-1);
|
||||
|
||||
if (options.showDisassembled || options.showLineAndLocalVariableTables)
|
||||
println();
|
||||
}
|
||||
|
@ -270,6 +272,7 @@ public class ClassWriter extends BasicWriter {
|
|||
protected void writeMethods() {
|
||||
for (Method m: classFile.methods)
|
||||
writeMethod(m);
|
||||
setPendingNewline(false);
|
||||
}
|
||||
|
||||
protected void writeMethod(Method m) {
|
||||
|
@ -278,14 +281,6 @@ public class ClassWriter extends BasicWriter {
|
|||
|
||||
method = m;
|
||||
|
||||
if (!(options.showLineAndLocalVariableTables
|
||||
|| options.showDisassembled
|
||||
|| options.verbose
|
||||
|| options.showInternalSignatures
|
||||
|| options.showAllAttrs)) {
|
||||
print(" ");
|
||||
}
|
||||
|
||||
AccessFlags flags = m.access_flags;
|
||||
|
||||
Descriptor d;
|
||||
|
@ -333,16 +328,6 @@ public class ClassWriter extends BasicWriter {
|
|||
if (e_attr != null) { // if there are generic exceptions, there must be erased exceptions
|
||||
if (e_attr instanceof Exceptions_attribute) {
|
||||
Exceptions_attribute exceptions = (Exceptions_attribute) e_attr;
|
||||
if (options.compat) { // Bug XXXXXXX whitespace
|
||||
if (!(options.showLineAndLocalVariableTables
|
||||
|| options.showDisassembled
|
||||
|| options.verbose
|
||||
|| options.showInternalSignatures
|
||||
|| options.showAllAttrs)) {
|
||||
print(" ");
|
||||
}
|
||||
print(" ");
|
||||
}
|
||||
print(" throws ");
|
||||
if (methodExceptions != null) { // use generic list if available
|
||||
writeList("", methodExceptions, "");
|
||||
|
@ -358,14 +343,17 @@ public class ClassWriter extends BasicWriter {
|
|||
}
|
||||
}
|
||||
|
||||
print(";");
|
||||
println();
|
||||
println(";");
|
||||
|
||||
if (options.showInternalSignatures)
|
||||
println(" Signature: " + getValue(m.descriptor));
|
||||
indent(+1);
|
||||
|
||||
if (options.verbose && !options.compat)
|
||||
writeList(" flags: ", flags.getMethodFlags(), NEWLINE);
|
||||
if (options.showInternalSignatures) {
|
||||
println("Signature: " + getValue(m.descriptor));
|
||||
}
|
||||
|
||||
if (options.verbose && !options.compat) {
|
||||
writeList("flags: ", flags.getMethodFlags(), NEWLINE);
|
||||
}
|
||||
|
||||
Code_attribute code = null;
|
||||
Attribute c_attr = m.attributes.get(Attribute.Code);
|
||||
|
@ -378,33 +366,35 @@ public class ClassWriter extends BasicWriter {
|
|||
|
||||
if (options.showDisassembled && !options.showAllAttrs) {
|
||||
if (code != null) {
|
||||
println(" Code:");
|
||||
println("Code:");
|
||||
codeWriter.writeInstrs(code);
|
||||
codeWriter.writeExceptionTable(code);
|
||||
}
|
||||
println();
|
||||
}
|
||||
|
||||
if (options.showLineAndLocalVariableTables) {
|
||||
if (code != null)
|
||||
if (code != null) {
|
||||
attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool);
|
||||
println();
|
||||
if (code != null)
|
||||
attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool);
|
||||
println();
|
||||
println();
|
||||
}
|
||||
}
|
||||
|
||||
if (options.showAllAttrs) {
|
||||
Attribute[] attrs = m.attributes.attrs;
|
||||
for (Attribute attr: attrs)
|
||||
attrWriter.write(m, attr, constant_pool);
|
||||
|
||||
// // the following condition is to mimic old javap
|
||||
// if (!(attrs.length > 0 &&
|
||||
// attrs[attrs.length - 1] instanceof Exceptions_attribute))
|
||||
println();
|
||||
}
|
||||
|
||||
indent(-1);
|
||||
|
||||
// set pendingNewline to write a newline before the next method (if any)
|
||||
// if a separator is desired
|
||||
setPendingNewline(
|
||||
options.showDisassembled ||
|
||||
options.showAllAttrs ||
|
||||
options.showInternalSignatures ||
|
||||
options.showLineAndLocalVariableTables ||
|
||||
options.verbose);
|
||||
}
|
||||
|
||||
void writeModifiers(Collection<String> items) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue