< prev index next >

src/java.base/share/classes/java/lang/reflect/Method.java

Print this page




 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 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&trade; 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();




 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&trade; 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();


< prev index next >