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

ParameterizedTypeImpl should override toString

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • None
    • generic
    • generic

      The ParameterizedType implementation returned by getGenericParameterTypes does not override toString, so printing out one these beasts yields no useful information. The following program illustrates the problem:

      import java.util.*;
      import java.lang.reflect.*;

      public class Junk {
          public static void main(String[] args) throws Exception {
              System.out.println(Junk.class.getMethod("foo", List.class).
                                 getGenericParameterTypes()[0]);
          }

          public void foo(List<String> dogs) {}
      }

      Running this program prints:

      sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@1a758cb

            darcy Joe Darcy
            jjb Josh Bloch
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: