Merge

Mon, 10 Aug 2009 09:36:40 -0700

author
asaha
date
Mon, 10 Aug 2009 09:36:40 -0700
changeset 364
91852fb12e2e
parent 363
21f1d2462c7c
parent 355
961dc3acdb06
child 365
38f54dbd2e5b

Merge

     1.1 --- a/.hgtags	Fri Aug 07 11:32:20 2009 -0700
     1.2 +++ b/.hgtags	Mon Aug 10 09:36:40 2009 -0700
     1.3 @@ -42,3 +42,4 @@
     1.4  7e0056ded28c802609d2bd79bfcda551d72a3fec jdk7-b65
     1.5  634f519d6f9a602b16bba1c7cd4a17242a8f6889 jdk7-b66
     1.6  14b1a8ede95493fc53c37ff2626f1f98ce94d108 jdk7-b67
     1.7 +95c1212b07e33b1b8c689b1d279d82ffd5a56e43 jdk7-b68
     2.1 --- a/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Fri Aug 07 11:32:20 2009 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Mon Aug 10 09:36:40 2009 -0700
     2.3 @@ -435,7 +435,7 @@
     2.4          }
     2.5  
     2.6          public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, ClassOutputStream out) {
     2.7 -            out.writeByte(attr.local_variable_table.length);
     2.8 +            out.writeShort(attr.local_variable_table.length);
     2.9              for (LocalVariableTypeTable_attribute.Entry e: attr.local_variable_table)
    2.10                  writeLocalVariableTypeTableEntry(e, out);
    2.11              return null;
     3.1 --- a/src/share/classes/com/sun/tools/javap/CodeWriter.java	Fri Aug 07 11:32:20 2009 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java	Mon Aug 10 09:36:40 2009 -0700
     3.3 @@ -117,7 +117,7 @@
     3.4      }
     3.5  
     3.6      public void writeInstr(Instruction instr) {
     3.7 -        print(String.format("%4d: %-12s ", instr.getPC(), instr.getMnemonic()));
     3.8 +        print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
     3.9          instr.accept(instructionPrinter, null);
    3.10          println();
    3.11      }
    3.12 @@ -140,7 +140,7 @@
    3.13          }
    3.14  
    3.15          public Void visitConstantPoolRef(Instruction instr, int index, Void p) {
    3.16 -            print("#" + index + ";");
    3.17 +            print("#" + index);
    3.18              tab();
    3.19              print("// ");
    3.20              printConstant(index);
    3.21 @@ -148,7 +148,7 @@
    3.22          }
    3.23  
    3.24          public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Void p) {
    3.25 -            print("#" + index + ",  " + value + ";");
    3.26 +            print("#" + index + ",  " + value);
    3.27              tab();
    3.28              print("// ");
    3.29              printConstant(index);
    3.30 @@ -170,7 +170,7 @@
    3.31              print("{ // " + npairs);
    3.32              indent(+1);
    3.33              for (int i = 0; i < npairs; i++) {
    3.34 -                print("\n" + matches[i] + ": " + (pc + offsets[i]) + ";");
    3.35 +                print("\n" + matches[i] + ": " + (pc + offsets[i]));
    3.36              }
    3.37              print("\ndefault: " + (pc + default_) + " }");
    3.38              indent(-1);
    3.39 @@ -182,7 +182,7 @@
    3.40              print("{ //" + low + " to " + high);
    3.41              indent(+1);
    3.42              for (int i = 0; i < offsets.length; i++) {
    3.43 -                print("\n" + (low + i) + ": " + (pc + offsets[i]) + ";");
    3.44 +                print("\n" + (low + i) + ": " + (pc + offsets[i]));
    3.45              }
    3.46              print("\ndefault: " + (pc + default_) + " }");
    3.47              indent(-1);
     4.1 --- a/src/share/classes/com/sun/tools/javap/ConstantWriter.java	Fri Aug 07 11:32:20 2009 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javap/ConstantWriter.java	Mon Aug 10 09:36:40 2009 -0700
     4.3 @@ -62,69 +62,69 @@
     4.4      protected void writeConstantPool(ConstantPool constant_pool) {
     4.5          ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() {
     4.6              public Integer visitClass(CONSTANT_Class_info info, Void p) {
     4.7 -                print("#" + info.name_index + ";");
     4.8 +                print("#" + info.name_index);
     4.9                  tab();
    4.10                  println("//  " + stringValue(info));
    4.11                  return 1;
    4.12              }
    4.13  
    4.14              public Integer visitDouble(CONSTANT_Double_info info, Void p) {
    4.15 -                println(stringValue(info) + ";");
    4.16 +                println(stringValue(info));
    4.17                  return 2;
    4.18              }
    4.19  
    4.20              public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) {
    4.21 -                print("#" + info.class_index + ".#" + info.name_and_type_index + ";");
    4.22 +                print("#" + info.class_index + ".#" + info.name_and_type_index);
    4.23                  tab();
    4.24                  println("//  " + stringValue(info));
    4.25                  return 1;
    4.26              }
    4.27  
    4.28              public Integer visitFloat(CONSTANT_Float_info info, Void p) {
    4.29 -                println(stringValue(info) + ";");
    4.30 +                println(stringValue(info));
    4.31                  return 1;
    4.32              }
    4.33  
    4.34              public Integer visitInteger(CONSTANT_Integer_info info, Void p) {
    4.35 -                println(stringValue(info) + ";");
    4.36 +                println(stringValue(info));
    4.37                  return 1;
    4.38              }
    4.39  
    4.40              public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
    4.41 -                print("#" + info.class_index + ".#" + info.name_and_type_index + ";");
    4.42 +                print("#" + info.class_index + ".#" + info.name_and_type_index);
    4.43                  tab();
    4.44                  println("//  " + stringValue(info));
    4.45                  return 1;
    4.46              }
    4.47  
    4.48              public Integer visitLong(CONSTANT_Long_info info, Void p) {
    4.49 -                println(stringValue(info) + ";");
    4.50 +                println(stringValue(info));
    4.51                  return 2;
    4.52              }
    4.53  
    4.54              public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
    4.55 -                print("#" + info.name_index + ":#" + info.type_index + ";");
    4.56 +                print("#" + info.name_index + ":#" + info.type_index);
    4.57                  tab();
    4.58                  println("//  " + stringValue(info));
    4.59                  return 1;
    4.60              }
    4.61  
    4.62              public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) {
    4.63 -                print("#" + info.class_index + ".#" + info.name_and_type_index + ";");
    4.64 +                print("#" + info.class_index + ".#" + info.name_and_type_index);
    4.65                  tab();
    4.66                  println("//  " + stringValue(info));
    4.67                  return 1;
    4.68              }
    4.69  
    4.70              public Integer visitString(CONSTANT_String_info info, Void p) {
    4.71 -                print("#" + info.string_index + ";");
    4.72 +                print("#" + info.string_index);
    4.73                  tab();
    4.74                  println("//  " + stringValue(info));
    4.75                  return 1;
    4.76              }
    4.77  
    4.78              public Integer visitUtf8(CONSTANT_Utf8_info info, Void p) {
    4.79 -                println(stringValue(info) + ";");
    4.80 +                println(stringValue(info));
    4.81                  return 1;
    4.82              }
    4.83  
    4.84 @@ -134,10 +134,10 @@
    4.85          int width = String.valueOf(constant_pool.size()).length() + 1;
    4.86          int cpx = 1;
    4.87          while (cpx < constant_pool.size()) {
    4.88 -            print(String.format("const %" + width + "s", ("#" + cpx)));
    4.89 +            print(String.format("%" + width + "s", ("#" + cpx)));
    4.90              try {
    4.91                  CPInfo cpInfo = constant_pool.get(cpx);
    4.92 -                print(String.format(" = %-15s ", tagName(cpInfo.getTag())));
    4.93 +                print(String.format(" = %-18s ", cpTagName(cpInfo)));
    4.94                  cpx += cpInfo.accept(v, null);
    4.95              } catch (ConstantPool.InvalidIndex ex) {
    4.96                  // should not happen
    4.97 @@ -178,10 +178,15 @@
    4.98          print(tagName(tag) + " " + stringValue(cpInfo));
    4.99      }
   4.100  
   4.101 +    String cpTagName(CPInfo cpInfo) {
   4.102 +        String n = cpInfo.getClass().getSimpleName();
   4.103 +        return n.replace("CONSTANT_", "").replace("_info", "");
   4.104 +    }
   4.105 +
   4.106      String tagName(int tag) {
   4.107          switch (tag) {
   4.108              case CONSTANT_Utf8:
   4.109 -                return "Asciz";
   4.110 +                return "Utf8";
   4.111              case CONSTANT_Integer:
   4.112                  return "int";
   4.113              case CONSTANT_Float:
   4.114 @@ -203,7 +208,7 @@
   4.115              case CONSTANT_NameAndType:
   4.116                  return "NameAndType";
   4.117              default:
   4.118 -                return "unknown tag";
   4.119 +                return "(unknown tag)";
   4.120          }
   4.121      }
   4.122  
     5.1 --- a/test/tools/javac/code/ArrayClone.java	Fri Aug 07 11:32:20 2009 -0700
     5.2 +++ b/test/tools/javac/code/ArrayClone.java	Mon Aug 10 09:36:40 2009 -0700
     5.3 @@ -48,7 +48,7 @@
     5.4          System.out.println(out);
     5.5  
     5.6          for (String line: out.split("\n")) {
     5.7 -            String match = "[ \t]+[0-9]+:[ \t]+invokevirtual[ \t]+#[0-9]+;[ \t]+// Method \"\\[Ljava/lang/String;\".clone:\\(\\)Ljava/lang/Object;";
     5.8 +            String match = "[ \t]+[0-9]+:[ \t]+invokevirtual[ \t]+#[0-9]+[ \t]+// Method \"\\[Ljava/lang/String;\".clone:\\(\\)Ljava/lang/Object;";
     5.9              if (line.matches(match))
    5.10                  return;
    5.11          }
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javap/T6868539.java	Mon Aug 10 09:36:40 2009 -0700
     6.3 @@ -0,0 +1,96 @@
     6.4 +/*
     6.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    6.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    6.24 + * have any questions.
    6.25 + */
    6.26 +
    6.27 +/*
    6.28 + * @test
    6.29 + * @bug 6868539 6868548
    6.30 + * @summary javap should use current names for constant pool entries,
    6.31 + *              remove spurious ';' from constant pool entries
    6.32 + */
    6.33 +
    6.34 +import java.io.*;
    6.35 +import java.util.*;
    6.36 +
    6.37 +public class T6868539
    6.38 +
    6.39 +{
    6.40 +    public static void main(String... args) {
    6.41 +        new T6868539().run();
    6.42 +    }
    6.43 +
    6.44 +    void run() {
    6.45 +        verify("T6868539", "Utf8 +java/lang/String");                                   // 1: Utf8
    6.46 +                                                                                        // 2: currently unused
    6.47 +        verify("T6868539", "Integer +123456");                                          // 3: Integer
    6.48 +        verify("T6868539", "Float +123456.0f");                                         // 4: Float
    6.49 +        verify("T6868539", "Long +123456l");                                            // 5: Long
    6.50 +        verify("T6868539", "Double +123456.0d");                                        // 6: Double
    6.51 +        verify("T6868539", "Class +#[0-9]+ +// + T6868539");                            // 7: Class
    6.52 +        verify("T6868539", "String +#[0-9]+ +// + not found");                          // 8: String
    6.53 +        verify("T6868539", "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I");       // 9: Fieldref
    6.54 +        verify("T6868539", "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V");   // 10: Methodref
    6.55 +        verify("T6868539", "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
    6.56 +                                                                                        // 11: InterfaceMethodref
    6.57 +        verify("T6868539", "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V");            // 12: NameAndType
    6.58 +        if (errors > 0)
    6.59 +            throw new Error(errors + " found.");
    6.60 +    }
    6.61 +
    6.62 +    void verify(String className, String... expects) {
    6.63 +        String output = javap(className);
    6.64 +        for (String expect: expects) {
    6.65 +            if (!output.matches("(?s).*" + expect + ".*"))
    6.66 +                error(expect + " not found");
    6.67 +        }
    6.68 +    }
    6.69 +
    6.70 +    void error(String msg) {
    6.71 +        System.err.println(msg);
    6.72 +        errors++;
    6.73 +    }
    6.74 +
    6.75 +    int errors;
    6.76 +
    6.77 +    String javap(String className) {
    6.78 +        String testClasses = System.getProperty("test.classes", ".");
    6.79 +        StringWriter sw = new StringWriter();
    6.80 +        PrintWriter out = new PrintWriter(sw);
    6.81 +        String[] args = { "-v", "-classpath", testClasses, className };
    6.82 +        int rc = com.sun.tools.javap.Main.run(args, out);
    6.83 +        if (rc != 0)
    6.84 +            throw new Error("javap failed. rc=" + rc);
    6.85 +        out.close();
    6.86 +        String output = sw.toString();
    6.87 +        System.out.println("class " + className);
    6.88 +        System.out.println(output);
    6.89 +        return output;
    6.90 +    }
    6.91 +
    6.92 +    int i = 123456;
    6.93 +    float f = 123456.f;
    6.94 +    double d = 123456.;
    6.95 +    long l = 123456L;
    6.96 +
    6.97 +    void m(Runnable r) { r.run(); }
    6.98 +}
    6.99 +

mercurial