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

(reflect) Concrete Type classes could define toString()

    XMLWordPrintable

    Details

      Description

      The Type instances that you get back from e.g. Method.getGenericReturnType() could define useful toString() methods. At the moment you get the default string, such as "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl@1e0be38". Existing reflection classes do define useful toString() methods, e.g. Method.toString() which may return "public abstract java.util.Set T.stringSet()". Having a useful toString() makes it much easier to produce meaningful exception messages in code that uses reflection ("Could not map " + parameterizedType + " to a factory").

      Incidentally Method.toString() could then use getGenericReturnType() and getGenericParameterTypes() instead of getReturnType() and getParameterTypes().

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              emcmanus Eamonn McManus
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: