-
Enhancement
-
Resolution: Fixed
-
P4
-
8
-
b25
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8226087 | 14 | Joe Darcy | P4 | Resolved | Fixed | team |
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.)
"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.)
- backported by
-
JDK-8226087 (reflect) Clarifications to javadoc for getGeneric*Type methods in j.l.r
- Resolved
- relates to
-
JDK-8225495 Note whether returned annotations are declaration annotations or type annotations
- Resolved
-
JDK-8225540 In core reflection note whether returned annotations are declaration or type annotations
- Resolved