Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8003537

javap use internal class name when printing bound of type variable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • tools
    • None
    • b112
    • Verified

    Description

      From: Remi Forax
      http://mail.openjdk.java.net/pipermail/compiler-dev/2012-November/005026.html

      Hi guys,
      I've noticed a small bug in javap, the declared type variables prints
      their bounds with '/' instead of '.'

      By example:
      public abstract <U extends java/lang/Object> U
      fold(java.util.functions.Factory<U>, java.util.functions.Combiner<U, T,
      U>, java.util.functions.BinaryOperator<U>);

      Here is the patch to use the type printer instead of toString() when
      printing
      the declaration of the type variable.
      It creates one JavaTypePrinter by methods because I haven't wanted to
      change the code too much,
      but maybe the same JavaTypePrinter should be used for all methods.

      cheers,
      Rémi

      diff -r bdcef2ef52d2 src/share/classes/com/sun/tools/javap/ClassWriter.java
      --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu Nov
      15 23:07:24 2012 -0800
      +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Fri Nov
      16 15:08:37 2012 +0100
      @@ -329,7 +329,7 @@
                        sb.append(suffix);
                    }

      - private void appendIfNotEmpty(StringBuilder sb, String
      prefix, List<? extends Type> list, String suffix) {
      + void appendIfNotEmpty(StringBuilder sb, String prefix,
      List<? extends Type> list, String suffix) {
                        if (!isEmpty(list))
                            append(sb, prefix, list, suffix);
                    }
      @@ -438,7 +438,10 @@

                writeModifiers(flags.getMethodModifiers());
                if (methodType != null) {
      - writeListIfNotEmpty("<", methodType.typeParamTypes, "> ");
      + JavaTypePrinter printer = new JavaTypePrinter(false);
      + StringBuilder builder = new StringBuilder();
      + printer.appendIfNotEmpty(builder, "<",
      methodType.typeParamTypes, "> ");
      + print(builder);
                }
                if (getName(m).equals("<init>")) {
                    print(getJavaName(classFile));

      Attachments

        Issue Links

          Activity

            People

              ksrini Kumar Srinivasan
              jjg Jonathan Gibbons
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: