src/share/classes/java/lang/reflect/Executable.java
Print this page
rev 10097 : 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
Reviewed-by: duke
*** 583,607 ****
}
/**
* Returns an {@code AnnotatedType} object that represents the use of a
* type to specify the receiver type of the method/constructor represented
! * by this Executable object. The receiver type of a method/constructor is
! * available only if the method/constructor has a <em>receiver
! * parameter</em> (JLS 8.4.1).
*
! * If this {@code Executable} object represents a constructor or instance
! * method that does not have a receiver parameter, or has a receiver
! * parameter with no annotations on its type, then the return value is an
! * {@code AnnotatedType} object representing an element with no
* annotations.
*
! * If this {@code Executable} object represents a static method, then the
! * return value is null.
*
* @return an object representing the receiver type of the method or
! * constructor represented by this {@code Executable}
*/
public AnnotatedType getAnnotatedReceiverType() {
if (Modifier.isStatic(this.getModifiers()))
return null;
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
--- 583,610 ----
}
/**
* Returns an {@code AnnotatedType} object that represents the use of a
* type to specify the receiver type of the method/constructor represented
! * by this {@code Executable} object.
*
! * The receiver type of a method/constructor is available only if the
! * method/constructor has a receiver parameter (JLS 8.4.1). If this {@code
! * Executable} object <em>represents an instance method or represents a
! * constructor of an inner member class</em>, and the
! * method/constructor <em>either</em> has no receiver parameter or has a
! * receiver parameter with no annotations on its type, then the return
! * value is an {@code AnnotatedType} object representing an element with no
* annotations.
*
! * If this {@code Executable} object represents a static method or
! * represents a constructor of a top level, static member, local, or
! * anoymous class, then the return value is null.
*
* @return an object representing the receiver type of the method or
! * constructor represented by this {@code Executable} or {@code null} if
! * this {@code Executable} can not have a receiver parameter
*/
public AnnotatedType getAnnotatedReceiverType() {
if (Modifier.isStatic(this.getModifiers()))
return null;
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),