8032869: remove support for legacy options in javap

Mon, 03 Mar 2014 16:08:06 +0400

author
kizune
date
Mon, 03 Mar 2014 16:08:06 +0400
changeset 2289
3fbda1dca565
parent 2288
4267f38a1706
child 2290
27c08b9195d1
child 2296
21685ef33d2b

8032869: remove support for legacy options in javap
Reviewed-by: ksrini

src/share/classes/com/sun/tools/classfile/Attribute.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javap/AttributeWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javap/ClassWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javap/JavapTask.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javap/Options.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javap/resources/javap.properties file | annotate | diff | comparison | revisions
test/tools/javap/InvalidOptions.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/classfile/Attribute.java	Thu Feb 20 18:28:46 2014 +0400
     1.2 +++ b/src/share/classes/com/sun/tools/classfile/Attribute.java	Mon Mar 03 16:08:06 2014 +0400
     1.3 @@ -71,10 +71,6 @@
     1.4              // defer init of standardAttributeClasses until after options set up
     1.5          }
     1.6  
     1.7 -        public void setCompat(boolean compat) {
     1.8 -            this.compat = compat;
     1.9 -        }
    1.10 -
    1.11          public Attribute createAttribute(ClassReader cr, int name_index, byte[] data)
    1.12                  throws IOException {
    1.13              if (standardAttributes == null) {
    1.14 @@ -109,9 +105,10 @@
    1.15          protected void init() {
    1.16              standardAttributes = new HashMap<String,Class<? extends Attribute>>();
    1.17              standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class);
    1.18 -            standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class);
    1.19 +            standardAttributes.put(BootstrapMethods,  BootstrapMethods_attribute.class);
    1.20              standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);
    1.21              standardAttributes.put(Code,              Code_attribute.class);
    1.22 +            standardAttributes.put(CompilationID,     CompilationID_attribute.class);
    1.23              standardAttributes.put(ConstantValue,     ConstantValue_attribute.class);
    1.24              standardAttributes.put(Deprecated,        Deprecated_attribute.class);
    1.25              standardAttributes.put(EnclosingMethod,   EnclosingMethod_attribute.class);
    1.26 @@ -120,29 +117,23 @@
    1.27              standardAttributes.put(LineNumberTable,   LineNumberTable_attribute.class);
    1.28              standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class);
    1.29              standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
    1.30 -
    1.31 -            if (!compat) { // old javap does not recognize recent attributes
    1.32 -                standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
    1.33 -                standardAttributes.put(CompilationID, CompilationID_attribute.class);
    1.34 -                standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
    1.35 -                standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
    1.36 -                standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
    1.37 -                standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
    1.38 -                standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
    1.39 -                standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
    1.40 -                standardAttributes.put(Signature,     Signature_attribute.class);
    1.41 -                standardAttributes.put(SourceID, SourceID_attribute.class);
    1.42 -            }
    1.43 -
    1.44 +            standardAttributes.put(MethodParameters,  MethodParameters_attribute.class);
    1.45 +            standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
    1.46 +            standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
    1.47 +            standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
    1.48 +            standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
    1.49 +            standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
    1.50 +            standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
    1.51 +            standardAttributes.put(Signature,         Signature_attribute.class);
    1.52              standardAttributes.put(SourceDebugExtension, SourceDebugExtension_attribute.class);
    1.53              standardAttributes.put(SourceFile,        SourceFile_attribute.class);
    1.54 +            standardAttributes.put(SourceID,          SourceID_attribute.class);
    1.55              standardAttributes.put(StackMap,          StackMap_attribute.class);
    1.56              standardAttributes.put(StackMapTable,     StackMapTable_attribute.class);
    1.57              standardAttributes.put(Synthetic,         Synthetic_attribute.class);
    1.58          }
    1.59  
    1.60          private Map<String,Class<? extends Attribute>> standardAttributes;
    1.61 -        private boolean compat; // don't support recent attrs in compatibility mode
    1.62      }
    1.63  
    1.64      public static Attribute read(ClassReader cr) throws IOException {
     2.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Thu Feb 20 18:28:46 2014 +0400
     2.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Mon Mar 03 16:08:06 2014 +0400
     2.3 @@ -226,10 +226,7 @@
     2.4      }
     2.5  
     2.6      public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
     2.7 -        if (options.compat) // BUG 6622216 javap names some attributes incorrectly
     2.8 -            print("Constant value: ");
     2.9 -        else
    2.10 -            print("ConstantValue: ");
    2.11 +        print("ConstantValue: ");
    2.12          constantWriter.write(attr.constantvalue_index);
    2.13          println();
    2.14          return null;
    2.15 @@ -290,20 +287,10 @@
    2.16  
    2.17      public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
    2.18          boolean first = true;
    2.19 -        if (options.compat) {
    2.20 -            writeInnerClassHeader();
    2.21 -            first = false;
    2.22 -        }
    2.23          for (int i = 0 ; i < attr.classes.length; i++) {
    2.24              InnerClasses_attribute.Info info = attr.classes[i];
    2.25              //access
    2.26              AccessFlags access_flags = info.inner_class_access_flags;
    2.27 -            if (options.compat) {
    2.28 -                // BUG 6622215: javap ignores certain relevant access flags
    2.29 -                access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
    2.30 -                // BUG 6622232: javap gets whitespace confused
    2.31 -                print("   ");
    2.32 -            }
    2.33              if (options.checkAccess(access_flags)) {
    2.34                  if (first) {
    2.35                      writeInnerClassHeader();
    2.36 @@ -345,11 +332,7 @@
    2.37      }
    2.38  
    2.39      private void writeInnerClassHeader() {
    2.40 -        if (options.compat) // BUG 6622216: javap names some attributes incorrectly
    2.41 -            print("InnerClass");
    2.42 -        else
    2.43 -            print("InnerClasses");
    2.44 -        println(":");
    2.45 +        println("InnerClasses:");
    2.46          indent(+1);
    2.47      }
    2.48  
    2.49 @@ -703,10 +686,7 @@
    2.50      }
    2.51  
    2.52      String toHex(byte b, int w) {
    2.53 -        if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
    2.54 -            return toHex((int) b, w);
    2.55 -        else
    2.56 -            return toHex(b & 0xff, w);
    2.57 +        return toHex(b & 0xff, w);
    2.58      }
    2.59  
    2.60      static String toHex(int i) {
     3.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Feb 20 18:28:46 2014 +0400
     3.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Mon Mar 03 16:08:06 2014 +0400
     3.3 @@ -120,7 +120,7 @@
     3.4      public void write(ClassFile cf) {
     3.5          setClassFile(cf);
     3.6  
     3.7 -        if ((options.sysInfo || options.verbose) && !options.compat) {
     3.8 +        if (options.sysInfo || options.verbose) {
     3.9              if (uri != null) {
    3.10                  if (uri.getScheme().equals("file"))
    3.11                      println("Classfile " + uri.getPath());
    3.12 @@ -152,7 +152,7 @@
    3.13              println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
    3.14          }
    3.15  
    3.16 -        if ((options.sysInfo || options.verbose) && !options.compat) {
    3.17 +        if (options.sysInfo || options.verbose) {
    3.18              indent(-1);
    3.19          }
    3.20  
    3.21 @@ -205,8 +205,7 @@
    3.22              attrWriter.write(cf, cf.attributes, constant_pool);
    3.23              println("minor version: " + cf.minor_version);
    3.24              println("major version: " + cf.major_version);
    3.25 -            if (!options.compat)
    3.26 -              writeList("flags: ", flags.getClassFlags(), "\n");
    3.27 +            writeList("flags: ", flags.getClassFlags(), "\n");
    3.28              indent(-1);
    3.29              constantWriter.writeConstantPool();
    3.30          } else {
    3.31 @@ -372,7 +371,7 @@
    3.32          }
    3.33          print(" ");
    3.34          print(getFieldName(f));
    3.35 -        if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
    3.36 +        if (options.showConstants) {
    3.37              Attribute a = f.attributes.get(Attribute.ConstantValue);
    3.38              if (a instanceof ConstantValue_attribute) {
    3.39                  print(" = ");
    3.40 @@ -390,7 +389,7 @@
    3.41          if (options.showDescriptors)
    3.42              println("descriptor: " + getValue(f.descriptor));
    3.43  
    3.44 -        if (options.verbose && !options.compat)
    3.45 +        if (options.verbose)
    3.46              writeList("flags: ", flags.getFieldFlags(), "\n");
    3.47  
    3.48          if (options.showAllAttrs) {
    3.49 @@ -487,7 +486,7 @@
    3.50              println("descriptor: " + getValue(m.descriptor));
    3.51          }
    3.52  
    3.53 -        if (options.verbose && !options.compat) {
    3.54 +        if (options.verbose) {
    3.55              writeList("flags: ", flags.getMethodFlags(), "\n");
    3.56          }
    3.57  
    3.58 @@ -553,13 +552,11 @@
    3.59      }
    3.60  
    3.61      Signature_attribute getSignature(Attributes attributes) {
    3.62 -        if (options.compat) // javap does not recognize recent attributes
    3.63 -            return null;
    3.64          return (Signature_attribute) attributes.get(Attribute.Signature);
    3.65      }
    3.66  
    3.67      String adjustVarargs(AccessFlags flags, String params) {
    3.68 -        if (flags.is(ACC_VARARGS) && !options.compat) {
    3.69 +        if (flags.is(ACC_VARARGS)) {
    3.70              int i = params.lastIndexOf("[]");
    3.71              if (i > 0)
    3.72                  return params.substring(0, i) + "..." + params.substring(i+2);
     4.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Thu Feb 20 18:28:46 2014 +0400
     4.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Mon Mar 03 16:08:06 2014 +0400
     4.3 @@ -195,48 +195,12 @@
     4.4              }
     4.5          },
     4.6  
     4.7 -//        new Option(false, "-all") {
     4.8 -//            void process(JavapTask task, String opt, String arg) {
     4.9 -//                task.options.showAllAttrs = true;
    4.10 -//            }
    4.11 -//        },
    4.12 -
    4.13 -        new Option(false, "-h") {
    4.14 -            void process(JavapTask task, String opt, String arg) throws BadArgs {
    4.15 -                throw task.new BadArgs("err.h.not.supported");
    4.16 -            }
    4.17 -        },
    4.18 -
    4.19 -        new Option(false, "-verify", "-verify-verbose") {
    4.20 -            void process(JavapTask task, String opt, String arg) throws BadArgs {
    4.21 -                throw task.new BadArgs("err.verify.not.supported");
    4.22 -            }
    4.23 -        },
    4.24 -
    4.25          new Option(false, "-sysinfo") {
    4.26              void process(JavapTask task, String opt, String arg) {
    4.27                  task.options.sysInfo = true;
    4.28              }
    4.29          },
    4.30  
    4.31 -        new Option(false, "-Xold") {
    4.32 -            void process(JavapTask task, String opt, String arg) throws BadArgs {
    4.33 -                task.log.println(task.getMessage("warn.Xold.not.supported"));
    4.34 -            }
    4.35 -        },
    4.36 -
    4.37 -        new Option(false, "-Xnew") {
    4.38 -            void process(JavapTask task, String opt, String arg) throws BadArgs {
    4.39 -                // ignore: this _is_ the new version
    4.40 -            }
    4.41 -        },
    4.42 -
    4.43 -        new Option(false, "-XDcompat") {
    4.44 -            void process(JavapTask task, String opt, String arg) {
    4.45 -                task.options.compat = true;
    4.46 -            }
    4.47 -        },
    4.48 -
    4.49          new Option(false, "-XDdetails") {
    4.50              void process(JavapTask task, String opt, String arg) {
    4.51                  task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
    4.52 @@ -524,7 +488,7 @@
    4.53                  throw new BadArgs("err.unknown.option", arg).showUsage(true);
    4.54          }
    4.55  
    4.56 -        if (!options.compat && options.accessOptions.size() > 1) {
    4.57 +        if (options.accessOptions.size() > 1) {
    4.58              StringBuilder sb = new StringBuilder();
    4.59              for (String opt: options.accessOptions) {
    4.60                  if (sb.length() > 0)
    4.61 @@ -589,8 +553,6 @@
    4.62          SourceWriter sourceWriter = SourceWriter.instance(context);
    4.63          sourceWriter.setFileManager(fileManager);
    4.64  
    4.65 -        attributeFactory.setCompat(options.compat);
    4.66 -
    4.67          int result = EXIT_OK;
    4.68  
    4.69          for (String className: classes) {
     5.1 --- a/src/share/classes/com/sun/tools/javap/Options.java	Thu Feb 20 18:28:46 2014 +0400
     5.2 +++ b/src/share/classes/com/sun/tools/javap/Options.java	Mon Mar 03 16:08:06 2014 +0400
     5.3 @@ -88,6 +88,4 @@
     5.4      public boolean showInnerClasses;
     5.5      public int indentWidth = 2;   // #spaces per indentWidth level; must be > 0
     5.6      public int tabColumn = 40;    // column number for comments; must be > 0
     5.7 -
     5.8 -    public boolean compat;             // bug-for-bug compatibility mode with old javap
     5.9  }
     6.1 --- a/src/share/classes/com/sun/tools/javap/resources/javap.properties	Thu Feb 20 18:28:46 2014 +0400
     6.2 +++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties	Mon Mar 03 16:08:06 2014 +0400
     6.3 @@ -6,7 +6,6 @@
     6.4  err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, and include the following information:\n{1}
     6.5  err.end.of.file=unexpected end of file while reading {0}
     6.6  err.file.not.found=file not found: {0}
     6.7 -err.h.not.supported=-h is no longer available - use the 'javah' program
     6.8  err.incompatible.options=bad combination of options: {0}
     6.9  err.internal.error=internal error: {0} {1} {2}
    6.10  err.invalid.arg.for.option=invalid argument for option: {0}
    6.11 @@ -16,11 +15,9 @@
    6.12  err.not.standard.file.manager=can only specify class files when using a standard file manager
    6.13  err.invalid.use.of.option=invalid use of option: {0}
    6.14  err.unknown.option=unknown option: {0}
    6.15 -err.verify.not.supported=-verify not supported
    6.16  err.no.SourceFile.attribute=no SourceFile attribute
    6.17  err.source.file.not.found=source file not found
    6.18  err.bad.innerclasses.attribute=bad InnerClasses attribute for {0}
    6.19 -warn.Xold.not.supported=-Xold is no longer available
    6.20  
    6.21  main.usage.summary=\
    6.22  Usage: {0} <options> <classes>\n\
     7.1 --- a/test/tools/javap/InvalidOptions.java	Thu Feb 20 18:28:46 2014 +0400
     7.2 +++ b/test/tools/javap/InvalidOptions.java	Mon Mar 03 16:08:06 2014 +0400
     7.3 @@ -24,7 +24,7 @@
     7.4  /*
     7.5   * @test
     7.6   * @bug 8027411
     7.7 - * @summary test invalid options -h and -b
     7.8 + * @summary test an invalid option
     7.9   */
    7.10  
    7.11  import java.io.*;
    7.12 @@ -39,7 +39,6 @@
    7.13      }
    7.14  
    7.15      void run() throws Exception {
    7.16 -        test(2, "-h", "Error: -h is no longer available - use the javah program");
    7.17          test(2, "-b", "Error: unknown option: -b",
    7.18                        "Usage: javap <options> <classes>",
    7.19                        "use -help for a list of possible options");

mercurial