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

(reflect) Clarifications to javadoc for getGeneric*Type methods in j.l.r

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 13
    • 8
    • core-libs

        1) In java.lang.reflect.Field.getGenericType(), the text:

        "If the Type is a parameterized type, the Type object returned must accurately reflect the actual type parameters used in the source code."

        should be:

        "If the declared type of the field is a parameterized type, the Type object returned must accurately reflect the type arguments used in the source code."

        NB What exactly is being created or resolved in: "If the type of the underlying field is a type variable or a parameterized type, it is created. Otherwise, it is resolved."

        NB Since the Type object is not restricted to representing generic types (in fact it never does! generic type != parameterized type), a better name for the method would be Field.getDeclaredType.

        2) Similar changes apply to Method and Constructor:

        Type[] getGenericExceptionTypes()
        Type[] getGenericParameterTypes()
        Type getGenericReturnType()

        3) In Field.getAnnotation/getDeclaredAnnotations, Method.getAnnotation/getDeclaredAnnotations/getParameterAnnotations, and Constructor.getAnnotation/getDeclaredAnnotations/getParameterAnnotations, please state that the returned annotations are all declaration annotations. (Please do not turn "Returns an array of arrays that represent the annotations" into "Returns an array of arrays that represent the DECLARATION annotations" because that implies that non-declaration annotations might exist on the element, which cannot happen.)

              darcy Joe Darcy
              abuckley Alex Buckley
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: