--- a/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java Wed Jan 29 14:32:27 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -71,10 +71,6 @@
// defer init of standardAttributeClasses until after options set up
}
- public void setCompat(boolean compat) {
- this.compat = compat;
- }
-
public Attribute createAttribute(ClassReader cr, int name_index, byte[] data)
throws IOException {
if (standardAttributes == null) {
@@ -109,9 +105,10 @@
protected void init() {
standardAttributes = new HashMap<>();
standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class);
- standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class);
+ standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class);
standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);
standardAttributes.put(Code, Code_attribute.class);
+ standardAttributes.put(CompilationID, CompilationID_attribute.class);
standardAttributes.put(ConstantValue, ConstantValue_attribute.class);
standardAttributes.put(Deprecated, Deprecated_attribute.class);
standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class);
@@ -120,29 +117,23 @@
standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class);
standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class);
standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
-
- if (!compat) { // old javap does not recognize recent attributes
- standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
- standardAttributes.put(CompilationID, CompilationID_attribute.class);
- standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
- standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
- standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
- standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
- standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
- standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
- standardAttributes.put(Signature, Signature_attribute.class);
- standardAttributes.put(SourceID, SourceID_attribute.class);
- }
-
+ standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
+ standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
+ standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
+ standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
+ standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
+ standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
+ standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
+ standardAttributes.put(Signature, Signature_attribute.class);
standardAttributes.put(SourceDebugExtension, SourceDebugExtension_attribute.class);
standardAttributes.put(SourceFile, SourceFile_attribute.class);
+ standardAttributes.put(SourceID, SourceID_attribute.class);
standardAttributes.put(StackMap, StackMap_attribute.class);
standardAttributes.put(StackMapTable, StackMapTable_attribute.class);
standardAttributes.put(Synthetic, Synthetic_attribute.class);
}
private Map<String,Class<? extends Attribute>> standardAttributes;
- private boolean compat; // don't support recent attrs in compatibility mode
}
public static Attribute read(ClassReader cr) throws IOException {
--- a/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jan 29 14:32:27 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -227,10 +227,7 @@
}
public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
- if (options.compat) // BUG 6622216 javap names some attributes incorrectly
- print("Constant value: ");
- else
- print("ConstantValue: ");
+ print("ConstantValue: ");
constantWriter.write(attr.constantvalue_index);
println();
return null;
@@ -291,20 +288,10 @@
public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
boolean first = true;
- if (options.compat) {
- writeInnerClassHeader();
- first = false;
- }
for (int i = 0 ; i < attr.classes.length; i++) {
InnerClasses_attribute.Info info = attr.classes[i];
//access
AccessFlags access_flags = info.inner_class_access_flags;
- if (options.compat) {
- // BUG 6622215: javap ignores certain relevant access flags
- access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
- // BUG 6622232: javap gets whitespace confused
- print(" ");
- }
if (options.checkAccess(access_flags)) {
if (first) {
writeInnerClassHeader();
@@ -346,11 +333,7 @@
}
private void writeInnerClassHeader() {
- if (options.compat) // BUG 6622216: javap names some attributes incorrectly
- print("InnerClass");
- else
- print("InnerClasses");
- println(":");
+ println("InnerClasses:");
indent(+1);
}
@@ -711,10 +694,7 @@
}
String toHex(byte b, int w) {
- if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
- return toHex((int) b, w);
- else
- return toHex(b & 0xff, w);
+ return toHex(b & 0xff, w);
}
static String toHex(int i) {
--- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Jan 29 14:32:27 2014 -0800
@@ -120,7 +120,7 @@
public void write(ClassFile cf) {
setClassFile(cf);
- if ((options.sysInfo || options.verbose) && !options.compat) {
+ if (options.sysInfo || options.verbose) {
if (uri != null) {
if (uri.getScheme().equals("file"))
println("Classfile " + uri.getPath());
@@ -152,7 +152,7 @@
println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
}
- if ((options.sysInfo || options.verbose) && !options.compat) {
+ if (options.sysInfo || options.verbose) {
indent(-1);
}
@@ -205,8 +205,7 @@
attrWriter.write(cf, cf.attributes, constant_pool);
println("minor version: " + cf.minor_version);
println("major version: " + cf.major_version);
- if (!options.compat)
- writeList("flags: ", flags.getClassFlags(), "\n");
+ writeList("flags: ", flags.getClassFlags(), "\n");
indent(-1);
constantWriter.writeConstantPool();
} else {
@@ -372,7 +371,7 @@
}
print(" ");
print(getFieldName(f));
- if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
+ if (options.showConstants) {
Attribute a = f.attributes.get(Attribute.ConstantValue);
if (a instanceof ConstantValue_attribute) {
print(" = ");
@@ -390,7 +389,7 @@
if (options.showDescriptors)
println("descriptor: " + getValue(f.descriptor));
- if (options.verbose && !options.compat)
+ if (options.verbose)
writeList("flags: ", flags.getFieldFlags(), "\n");
if (options.showAllAttrs) {
@@ -487,7 +486,7 @@
println("descriptor: " + getValue(m.descriptor));
}
- if (options.verbose && !options.compat) {
+ if (options.verbose) {
writeList("flags: ", flags.getMethodFlags(), "\n");
}
@@ -553,13 +552,11 @@
}
Signature_attribute getSignature(Attributes attributes) {
- if (options.compat) // javap does not recognize recent attributes
- return null;
return (Signature_attribute) attributes.get(Attribute.Signature);
}
String adjustVarargs(AccessFlags flags, String params) {
- if (flags.is(ACC_VARARGS) && !options.compat) {
+ if (flags.is(ACC_VARARGS)) {
int i = params.lastIndexOf("[]");
if (i > 0)
return params.substring(0, i) + "..." + params.substring(i+2);
--- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Wed Jan 29 14:32:27 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -195,48 +195,12 @@
}
},
-// new Option(false, "-all") {
-// void process(JavapTask task, String opt, String arg) {
-// task.options.showAllAttrs = true;
-// }
-// },
-
- new Option(false, "-h") {
- void process(JavapTask task, String opt, String arg) throws BadArgs {
- throw task.new BadArgs("err.h.not.supported");
- }
- },
-
- new Option(false, "-verify", "-verify-verbose") {
- void process(JavapTask task, String opt, String arg) throws BadArgs {
- throw task.new BadArgs("err.verify.not.supported");
- }
- },
-
new Option(false, "-sysinfo") {
void process(JavapTask task, String opt, String arg) {
task.options.sysInfo = true;
}
},
- new Option(false, "-Xold") {
- void process(JavapTask task, String opt, String arg) throws BadArgs {
- task.log.println(task.getMessage("warn.Xold.not.supported"));
- }
- },
-
- new Option(false, "-Xnew") {
- void process(JavapTask task, String opt, String arg) throws BadArgs {
- // ignore: this _is_ the new version
- }
- },
-
- new Option(false, "-XDcompat") {
- void process(JavapTask task, String opt, String arg) {
- task.options.compat = true;
- }
- },
-
new Option(false, "-XDdetails") {
void process(JavapTask task, String opt, String arg) {
task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
@@ -520,7 +484,7 @@
throw new BadArgs("err.unknown.option", arg).showUsage(true);
}
- if (!options.compat && options.accessOptions.size() > 1) {
+ if (options.accessOptions.size() > 1) {
StringBuilder sb = new StringBuilder();
for (String opt: options.accessOptions) {
if (sb.length() > 0)
@@ -581,8 +545,6 @@
SourceWriter sourceWriter = SourceWriter.instance(context);
sourceWriter.setFileManager(fileManager);
- attributeFactory.setCompat(options.compat);
-
int result = EXIT_OK;
for (String className: classes) {
--- a/langtools/src/share/classes/com/sun/tools/javap/Options.java Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/src/share/classes/com/sun/tools/javap/Options.java Wed Jan 29 14:32:27 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,4 @@
public boolean showInnerClasses;
public int indentWidth = 2; // #spaces per indentWidth level
public int tabColumn = 40; // column number for comments
-
- public boolean compat; // bug-for-bug compatibility mode with old javap
}
--- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Wed Jan 29 14:32:27 2014 -0800
@@ -6,7 +6,6 @@
err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, and include the following information:\n{1}
err.end.of.file=unexpected end of file while reading {0}
err.file.not.found=file not found: {0}
-err.h.not.supported=-h is no longer available - use the 'javah' program
err.incompatible.options=bad combination of options: {0}
err.internal.error=internal error: {0} {1} {2}
err.invalid.arg.for.option=invalid argument for option: {0}
@@ -15,11 +14,9 @@
err.no.classes.specified=no classes specified
err.not.standard.file.manager=can only specify class files when using a standard file manager
err.unknown.option=unknown option: {0}
-err.verify.not.supported=-verify not supported
err.no.SourceFile.attribute=no SourceFile attribute
err.source.file.not.found=source file not found
err.bad.innerclasses.attribute=bad InnerClasses attribute for {0}
-warn.Xold.not.supported=-Xold is no longer available
main.usage.summary=\
Usage: {0} <options> <classes>\n\
--- a/langtools/test/tools/javap/InvalidOptions.java Tue Jan 28 17:52:30 2014 -0500
+++ b/langtools/test/tools/javap/InvalidOptions.java Wed Jan 29 14:32:27 2014 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,8 @@
/*
* @test
- * @bug 8027411
- * @summary test invalid options -h and -b
+ * @bug 8027411 8032869
+ * @summary test an invalid option
*/
import java.io.*;
@@ -39,7 +39,6 @@
}
void run() throws Exception {
- test(2, "-h", "Error: -h is no longer available - use the javah program");
test(2, "-b", "Error: unknown option: -b",
"Usage: javap <options> <classes>",
"use -help for a list of possible options");