changeset 2326:27c08b9195d1 jdk8u20-b05

Merge
author lana
date Wed, 05 Mar 2014 15:35:06 -0800
parents a4932ddc3c7d (current diff) 3fbda1dca565 (diff)
children c6d0108aca9f
files
diffstat 10 files changed, 48 insertions(+), 124 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/classfile/Attribute.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/classfile/Attribute.java	Wed Mar 05 15:35:06 2014 -0800
@@ -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<String,Class<? extends Attribute>>();
             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/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Mar 05 15:35:06 2014 -0800
@@ -226,10 +226,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;
@@ -290,20 +287,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();
@@ -345,11 +332,7 @@
     }
 
     private void writeInnerClassHeader() {
-        if (options.compat) // BUG 6622216: javap names some attributes incorrectly
-            print("InnerClass");
-        else
-            print("InnerClasses");
-        println(":");
+        println("InnerClasses:");
         indent(+1);
     }
 
@@ -703,10 +686,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/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Mar 05 15:35:06 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/src/share/classes/com/sun/tools/javap/ConstantWriter.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/ConstantWriter.java	Wed Mar 05 15:35:06 2014 -0800
@@ -64,7 +64,7 @@
             public Integer visitClass(CONSTANT_Class_info info, Void p) {
                 print("#" + info.name_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
@@ -76,7 +76,7 @@
             public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) {
                 print("#" + info.class_index + ".#" + info.name_and_type_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
@@ -93,14 +93,14 @@
             public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
                 print("#" + info.class_index + ".#" + info.name_and_type_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
             public Integer visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) {
                 print("#" + info.bootstrap_method_attr_index + ":#" + info.name_and_type_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
@@ -112,21 +112,21 @@
             public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
                 print("#" + info.name_index + ":#" + info.type_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
             public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) {
                 print("#" + info.class_index + ".#" + info.name_and_type_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
             public Integer visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) {
                 print("#" + info.reference_kind.tag + ":#" + info.reference_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
@@ -140,7 +140,7 @@
             public Integer visitString(CONSTANT_String_info info, Void p) {
                 print("#" + info.string_index);
                 tab();
-                println("//  " + stringValue(info));
+                println("// " + stringValue(info));
                 return 1;
             }
 
--- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Wed Mar 05 15:35:06 2014 -0800
@@ -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);
@@ -524,7 +488,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)
@@ -589,8 +553,6 @@
         SourceWriter sourceWriter = SourceWriter.instance(context);
         sourceWriter.setFileManager(fileManager);
 
-        attributeFactory.setCompat(options.compat);
-
         int result = EXIT_OK;
 
         for (String className: classes) {
--- a/src/share/classes/com/sun/tools/javap/Options.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/Options.java	Wed Mar 05 15:35:06 2014 -0800
@@ -88,6 +88,4 @@
     public boolean showInnerClasses;
     public int indentWidth = 2;   // #spaces per indentWidth level; must be > 0
     public int tabColumn = 40;    // column number for comments; must be > 0
-
-    public boolean compat;             // bug-for-bug compatibility mode with old javap
 }
--- a/src/share/classes/com/sun/tools/javap/resources/javap.properties	Wed Mar 05 12:31:58 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties	Wed Mar 05 15:35:06 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}
@@ -16,11 +15,9 @@
 err.not.standard.file.manager=can only specify class files when using a standard file manager
 err.invalid.use.of.option=invalid use of option: {0}
 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/test/tools/javap/InvalidOptions.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/test/tools/javap/InvalidOptions.java	Wed Mar 05 15:35:06 2014 -0800
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8027411
- * @summary test invalid options -h and -b
+ * @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");
--- a/test/tools/javap/MethodParameters.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/test/tools/javap/MethodParameters.java	Wed Mar 05 15:35:06 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -44,24 +44,24 @@
     static final String Init0_expected =
         ("  Foo();\n" +
          "    descriptor: ()V\n" +
-         "    flags: \n" +
+         "    flags:\n" +
          "    Code:\n" +
          "      stack=1, locals=1, args_size=1\n" +
-         "         0: aload_0       \n" +
+         "         0: aload_0\n" +
          "         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\n" +
-         "         4: return        \n" +
+         "         4: return\n" +
          "      LineNumberTable:\n" +
          "        line 2: 0").replaceAll(" +", " ");
 
     static final String Init1_expected =
         ("  Foo(int);\n" +
          "    descriptor: (I)V\n" +
-         "    flags: \n" +
+         "    flags:\n" +
          "    Code:\n" +
          "      stack=1, locals=2, args_size=2\n" +
-         "         0: aload_0       \n" +
+         "         0: aload_0\n" +
          "         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\n" +
-         "         4: return        \n" +
+         "         4: return\n" +
          "      LineNumberTable:\n" +
          "        line 3: 0\n" +
          "    MethodParameters:\n" +
@@ -71,25 +71,25 @@
     static final String foo0_expected =
         ("  void foo0();\n" +
          "    descriptor: ()V\n" +
-         "    flags: \n" +
+         "    flags:\n" +
          "    Code:\n" +
          "      stack=0, locals=1, args_size=1\n" +
-         "         0: return        \n" +
+         "         0: return\n" +
          "      LineNumberTable:\n" +
          "        line 4: 0").replaceAll(" +", " ");
 
     static final String foo2_expected =
         ("  void foo2(int, int);\n" +
          "    descriptor: (II)V\n" +
-         "    flags: \n" +
+         "    flags:\n" +
          "    Code:\n" +
          "      stack=0, locals=3, args_size=3\n" +
-         "         0: return        \n" +
+         "         0: return\n" +
          "      LineNumberTable:\n" +
          "        line 5: 0\n" +
          "    MethodParameters:\n" +
          "      Name                                Flags\n" +
-         "      j                              \n" +
+         "      j\n" +
          "      k").replaceAll(" +", " ");
 
     static final File classesdir = new File("methodparameters");
--- a/test/tools/javap/T6868539.java	Wed Mar 05 12:31:58 2014 -0800
+++ b/test/tools/javap/T6868539.java	Wed Mar 05 15:35:06 2014 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6868539 6868548
+ * @bug 6868539 6868548 8035364
  * @summary javap should use current names for constant pool entries,
  *              remove spurious ';' from constant pool entries
  */
@@ -41,17 +41,17 @@
     void run() {
         String output = javap("T6868539");
         verify(output, "Utf8 +java/lang/String");                                   // 1: Utf8
-                                                                                        // 2: currently unused
+                                                                                    // 2: currently unused
         verify(output, "Integer +123456");                                          // 3: Integer
         verify(output, "Float +123456.0f");                                         // 4: Float
         verify(output, "Long +123456l");                                            // 5: Long
         verify(output, "Double +123456.0d");                                        // 6: Double
-        verify(output, "Class +#[0-9]+ +// + T6868539");                            // 7: Class
-        verify(output, "String +#[0-9]+ +// + not found");                          // 8: String
+        verify(output, "Class +#[0-9]+ +// +T6868539");                             // 7: Class
+        verify(output, "String +#[0-9]+ +// +not found");                           // 8: String
         verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I");       // 9: Fieldref
         verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V");   // 10: Methodref
         verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
-                                                                                        // 11: InterfaceMethodref
+                                                                                    // 11: InterfaceMethodref
         verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V");            // 12: NameAndType
         if (errors > 0)
             throw new Error(errors + " found.");