6937244: sqe ws7 tools javap/javap_t10a fail jdk7 b80 used output of javap is changed

Tue, 23 Mar 2010 18:05:54 -0700

author
jjg
date
Tue, 23 Mar 2010 18:05:54 -0700
changeset 528
dd30de080cb9
parent 527
6fad35d25b1e
child 529
3058880c0b8d

6937244: sqe ws7 tools javap/javap_t10a fail jdk7 b80 used output of javap is changed
Reviewed-by: darcy

src/share/classes/com/sun/tools/javap/ClassWriter.java file | annotate | diff | comparison | revisions
test/tools/javap/6937244/T6937244.java file | annotate | diff | comparison | revisions
test/tools/javap/6937244/T6937244A.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java	Thu Mar 18 18:52:44 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Tue Mar 23 18:05:54 2010 -0700
     1.3 @@ -225,15 +225,15 @@
     1.4          writeModifiers(flags.getFieldModifiers());
     1.5          Signature_attribute sigAttr = getSignature(f.attributes);
     1.6          if (sigAttr == null)
     1.7 -            print(getFieldType(f.descriptor));
     1.8 +            print(getJavaFieldType(f.descriptor));
     1.9          else {
    1.10              try {
    1.11                  Type t = sigAttr.getParsedSignature().getType(constant_pool);
    1.12 -                print(t);
    1.13 +                print(getJavaName(t.toString()));
    1.14              } catch (ConstantPoolException e) {
    1.15                  // report error?
    1.16                  // fall back on non-generic descriptor
    1.17 -                print(getFieldType(f.descriptor));
    1.18 +                print(getJavaFieldType(f.descriptor));
    1.19              }
    1.20          }
    1.21          print(" ");
    1.22 @@ -314,14 +314,14 @@
    1.23          }
    1.24          if (getName(m).equals("<init>")) {
    1.25              print(getJavaName(classFile));
    1.26 -            print(getParameterTypes(d, flags));
    1.27 +            print(getJavaParameterTypes(d, flags));
    1.28          } else if (getName(m).equals("<clinit>")) {
    1.29              print("{}");
    1.30          } else {
    1.31 -            print(getReturnType(d));
    1.32 +            print(getJavaReturnType(d));
    1.33              print(" ");
    1.34              print(getName(m));
    1.35 -            print(getParameterTypes(d, flags));
    1.36 +            print(getJavaParameterTypes(d, flags));
    1.37          }
    1.38  
    1.39          Attribute e_attr = m.attributes.get(Attribute.Exceptions);
    1.40 @@ -460,9 +460,9 @@
    1.41          }
    1.42      }
    1.43  
    1.44 -    String getFieldType(Descriptor d) {
    1.45 +    String getJavaFieldType(Descriptor d) {
    1.46          try {
    1.47 -            return d.getFieldType(constant_pool);
    1.48 +            return getJavaName(d.getFieldType(constant_pool));
    1.49          } catch (ConstantPoolException e) {
    1.50              return report(e);
    1.51          } catch (DescriptorException e) {
    1.52 @@ -470,9 +470,9 @@
    1.53          }
    1.54      }
    1.55  
    1.56 -    String getReturnType(Descriptor d) {
    1.57 +    String getJavaReturnType(Descriptor d) {
    1.58          try {
    1.59 -            return d.getReturnType(constant_pool);
    1.60 +            return getJavaName(d.getReturnType(constant_pool));
    1.61          } catch (ConstantPoolException e) {
    1.62              return report(e);
    1.63          } catch (DescriptorException e) {
    1.64 @@ -480,9 +480,9 @@
    1.65          }
    1.66      }
    1.67  
    1.68 -    String getParameterTypes(Descriptor d, AccessFlags flags) {
    1.69 +    String getJavaParameterTypes(Descriptor d, AccessFlags flags) {
    1.70          try {
    1.71 -            return adjustVarargs(flags, d.getParameterTypes(constant_pool));
    1.72 +            return getJavaName(adjustVarargs(flags, d.getParameterTypes(constant_pool)));
    1.73          } catch (ConstantPoolException e) {
    1.74              return report(e);
    1.75          } catch (DescriptorException e) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javap/6937244/T6937244.java	Tue Mar 23 18:05:54 2010 -0700
     2.3 @@ -0,0 +1,57 @@
     2.4 +/*
     2.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    2.24 + * have any questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug 6937244
    2.30 + * @summary fields display with JVMS names, not Java names
    2.31 + */
    2.32 +
    2.33 +import java.io.*;
    2.34 +
    2.35 +public class T6937244 {
    2.36 +    public static void main(String[] args) throws Exception {
    2.37 +        new T6937244().run();
    2.38 +    }
    2.39 +
    2.40 +    void run() throws Exception {
    2.41 +        StringWriter sw = new StringWriter();
    2.42 +        PrintWriter pw = new PrintWriter(sw);
    2.43 +        String[] args = { "java.lang.String" };
    2.44 +        int rc = com.sun.tools.javap.Main.run(args, pw);
    2.45 +        pw.close();
    2.46 +        String out = sw.toString();
    2.47 +        System.err.println(out);
    2.48 +        if (rc != 0)
    2.49 +            throw new Exception("unexpected exit from javap: " + rc);
    2.50 +        for (String line: out.split("[\r\n]+")) {
    2.51 +            if (line.contains("CASE_INSENSITIVE_ORDER")) {
    2.52 +                if (line.matches("\\s*\\Qpublic static final java.util.Comparator<java.lang.String> CASE_INSENSITIVE_ORDER;\\E\\s*"))
    2.53 +                    return;
    2.54 +                throw new Exception("declaration not shown as expected");
    2.55 +            }
    2.56 +        }
    2.57 +        throw new Exception("declaration of CASE_INSENSITIVE_ORDER not found");
    2.58 +    }
    2.59 +}
    2.60 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javap/6937244/T6937244A.java	Tue Mar 23 18:05:54 2010 -0700
     3.3 @@ -0,0 +1,90 @@
     3.4 +/*
     3.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    3.24 + * have any questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 6937244
    3.30 + * @summary fields display with JVMS names, not Java names
    3.31 + */
    3.32 +
    3.33 +import java.io.*;
    3.34 +import java.util.*;
    3.35 +
    3.36 +public class T6937244A {
    3.37 +    public static void main(String[] args) throws Exception {
    3.38 +        new T6937244A().run();
    3.39 +    }
    3.40 +
    3.41 +    void run() throws Exception {
    3.42 +        StringWriter sw = new StringWriter();
    3.43 +        PrintWriter pw = new PrintWriter(sw);
    3.44 +        String[] args = { "Test" };
    3.45 +        int rc = com.sun.tools.javap.Main.run(args, pw);
    3.46 +        pw.close();
    3.47 +        String out = sw.toString();
    3.48 +        System.err.println(out);
    3.49 +        if (rc != 0)
    3.50 +            throw new Exception("unexpected exit from javap: " + rc);
    3.51 +
    3.52 +        int count = 0;
    3.53 +
    3.54 +        for (String line: out.split("[\r\n]+")) {
    3.55 +            if (line.contains("extends")) {
    3.56 +                verify(line, "extends java.lang.Object implements java.util.List<java.lang.String>");
    3.57 +                count++;
    3.58 +            }
    3.59 +
    3.60 +            if (line.contains("field")) {
    3.61 +                verify(line, "java.util.List<java.lang.String> field");
    3.62 +                count++;
    3.63 +            }
    3.64 +
    3.65 +            if (line.contains("method")) {
    3.66 +                verify(line, "java.util.List<java.lang.String> method(java.util.List<java.lang.String>) throws java.lang.Exception");
    3.67 +                count++;
    3.68 +            }
    3.69 +        }
    3.70 +
    3.71 +        // final backstop check
    3.72 +        if (out.contains("/"))
    3.73 +            throw new Exception("unexpected \"/\" in output");
    3.74 +
    3.75 +        if (count != 3)
    3.76 +            throw new Exception("wrong number of matches found: " + count);
    3.77 +    }
    3.78 +
    3.79 +    void verify(String line, String expect) throws Exception {
    3.80 +        if (!line.contains(expect)) {
    3.81 +            System.err.println("line:   " + line);
    3.82 +            System.err.println("expect: " + expect);
    3.83 +            throw new Exception("expected string not found in line");
    3.84 +        }
    3.85 +    }
    3.86 +}
    3.87 +
    3.88 +
    3.89 +abstract class Test implements List<String> {
    3.90 +    public List<String> field;
    3.91 +    public List<String> method(List<String> arg) throws Exception { return null; }
    3.92 +}
    3.93 +

mercurial