252 else
253 return (TypeVariable<Method>[])new TypeVariable[0];
254 }
255
256 /**
257 * Returns a {@code Class} object that represents the formal return type
258 * of the method represented by this {@code Method} object.
259 *
260 * @return the return type for the method this object represents
261 */
262 public Class<?> getReturnType() {
263 return returnType;
264 }
265
266 /**
267 * Returns a {@code Type} object that represents the formal return
268 * type of the method represented by this {@code Method} object.
269 *
270 * <p>If the return type is a parameterized type,
271 * the {@code Type} object returned must accurately reflect
272 * the actual type parameters used in the source code.
273 *
274 * <p>If the return type is a type variable or a parameterized type, it
275 * is created. Otherwise, it is resolved.
276 *
277 * @return a {@code Type} object that represents the formal return
278 * type of the underlying method
279 * @throws GenericSignatureFormatError
280 * if the generic method signature does not conform to the format
281 * specified in
282 * <cite>The Java™ Virtual Machine Specification</cite>
283 * @throws TypeNotPresentException if the underlying method's
284 * return type refers to a non-existent type declaration
285 * @throws MalformedParameterizedTypeException if the
286 * underlying method's return typed refers to a parameterized
287 * type that cannot be instantiated for any reason
288 * @since 1.5
289 */
290 public Type getGenericReturnType() {
291 if (getGenericSignature() != null) {
292 return getGenericInfo().getReturnType();
675 Object result = AnnotationParser.parseMemberValue(
676 memberType, ByteBuffer.wrap(annotationDefault),
677 SharedSecrets.getJavaLangAccess().
678 getConstantPool(getDeclaringClass()),
679 getDeclaringClass());
680 if (result instanceof ExceptionProxy) {
681 if (result instanceof TypeNotPresentExceptionProxy) {
682 TypeNotPresentExceptionProxy proxy = (TypeNotPresentExceptionProxy)result;
683 throw new TypeNotPresentException(proxy.typeName(), proxy.getCause());
684 }
685 throw new AnnotationFormatError("Invalid default: " + this);
686 }
687 return result;
688 }
689
690 /**
691 * {@inheritDoc}
692 * @throws NullPointerException {@inheritDoc}
693 * @since 1.5
694 */
695 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
696 return super.getAnnotation(annotationClass);
697 }
698
699 /**
700 * {@inheritDoc}
701 * @since 1.5
702 */
703 public Annotation[] getDeclaredAnnotations() {
704 return super.getDeclaredAnnotations();
705 }
706
707 /**
708 * {@inheritDoc}
709 * @since 1.5
710 */
711 @Override
712 public Annotation[][] getParameterAnnotations() {
713 return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
714 }
715
716 /**
717 * {@inheritDoc}
718 * @since 1.8
719 */
720 @Override
721 public AnnotatedType getAnnotatedReturnType() {
722 return getAnnotatedReturnType0(getGenericReturnType());
|
252 else
253 return (TypeVariable<Method>[])new TypeVariable[0];
254 }
255
256 /**
257 * Returns a {@code Class} object that represents the formal return type
258 * of the method represented by this {@code Method} object.
259 *
260 * @return the return type for the method this object represents
261 */
262 public Class<?> getReturnType() {
263 return returnType;
264 }
265
266 /**
267 * Returns a {@code Type} object that represents the formal return
268 * type of the method represented by this {@code Method} object.
269 *
270 * <p>If the return type is a parameterized type,
271 * the {@code Type} object returned must accurately reflect
272 * the type arguments used in the source code.
273 *
274 * <p>If the return type is a type variable or a parameterized type, it
275 * is created. Otherwise, it is resolved.
276 *
277 * @return a {@code Type} object that represents the formal return
278 * type of the underlying method
279 * @throws GenericSignatureFormatError
280 * if the generic method signature does not conform to the format
281 * specified in
282 * <cite>The Java™ Virtual Machine Specification</cite>
283 * @throws TypeNotPresentException if the underlying method's
284 * return type refers to a non-existent type declaration
285 * @throws MalformedParameterizedTypeException if the
286 * underlying method's return typed refers to a parameterized
287 * type that cannot be instantiated for any reason
288 * @since 1.5
289 */
290 public Type getGenericReturnType() {
291 if (getGenericSignature() != null) {
292 return getGenericInfo().getReturnType();
675 Object result = AnnotationParser.parseMemberValue(
676 memberType, ByteBuffer.wrap(annotationDefault),
677 SharedSecrets.getJavaLangAccess().
678 getConstantPool(getDeclaringClass()),
679 getDeclaringClass());
680 if (result instanceof ExceptionProxy) {
681 if (result instanceof TypeNotPresentExceptionProxy) {
682 TypeNotPresentExceptionProxy proxy = (TypeNotPresentExceptionProxy)result;
683 throw new TypeNotPresentException(proxy.typeName(), proxy.getCause());
684 }
685 throw new AnnotationFormatError("Invalid default: " + this);
686 }
687 return result;
688 }
689
690 /**
691 * {@inheritDoc}
692 * @throws NullPointerException {@inheritDoc}
693 * @since 1.5
694 */
695 @Override
696 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
697 return super.getAnnotation(annotationClass);
698 }
699
700 /**
701 * {@inheritDoc}
702 * @since 1.5
703 */
704 @Override
705 public Annotation[] getDeclaredAnnotations() {
706 return super.getDeclaredAnnotations();
707 }
708
709 /**
710 * {@inheritDoc}
711 * @since 1.5
712 */
713 @Override
714 public Annotation[][] getParameterAnnotations() {
715 return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
716 }
717
718 /**
719 * {@inheritDoc}
720 * @since 1.8
721 */
722 @Override
723 public AnnotatedType getAnnotatedReturnType() {
724 return getAnnotatedReturnType0(getGenericReturnType());
|