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

Print this page




 548      *
 549      * <p>If the underlying method is static, the class that declared
 550      * the method is initialized if it has not already been initialized.
 551      *
 552      * <p>If the method completes normally, the value it returns is
 553      * returned to the caller of invoke; if the value has a primitive
 554      * type, it is first appropriately wrapped in an object. However,
 555      * if the value has the type of an array of a primitive type, the
 556      * elements of the array are <i>not</i> wrapped in objects; in
 557      * other words, an array of primitive type is returned.  If the
 558      * underlying method return type is void, the invocation returns
 559      * null.
 560      *
 561      * @param obj  the object the underlying method is invoked from
 562      * @param args the arguments used for the method call
 563      * @return the result of dispatching the method represented by
 564      * this object on {@code obj} with parameters
 565      * {@code args}
 566      *
 567      * @exception IllegalAccessException    if this {@code Method} object
 568      *              enforces Java language access control and the underlying
 569      *              method is inaccessible.
 570      * @exception IllegalArgumentException  if the method is an
 571      *              instance method and the specified object argument
 572      *              is not an instance of the class or interface
 573      *              declaring the underlying method (or of a subclass
 574      *              or implementor thereof); if the number of actual
 575      *              and formal parameters differ; if an unwrapping
 576      *              conversion for primitive arguments fails; or if,
 577      *              after possible unwrapping, a parameter value
 578      *              cannot be converted to the corresponding formal
 579      *              parameter type by a method invocation conversion.
 580      * @exception InvocationTargetException if the underlying method
 581      *              throws an exception.
 582      * @exception NullPointerException      if the specified object is null
 583      *              and the method is an instance method.
 584      * @exception ExceptionInInitializerError if the initialization
 585      * provoked by this method fails.
 586      */
 587     public Object invoke(Object obj, Object... args)
 588         throws IllegalAccessException, IllegalArgumentException,




 548      *
 549      * <p>If the underlying method is static, the class that declared
 550      * the method is initialized if it has not already been initialized.
 551      *
 552      * <p>If the method completes normally, the value it returns is
 553      * returned to the caller of invoke; if the value has a primitive
 554      * type, it is first appropriately wrapped in an object. However,
 555      * if the value has the type of an array of a primitive type, the
 556      * elements of the array are <i>not</i> wrapped in objects; in
 557      * other words, an array of primitive type is returned.  If the
 558      * underlying method return type is void, the invocation returns
 559      * null.
 560      *
 561      * @param obj  the object the underlying method is invoked from
 562      * @param args the arguments used for the method call
 563      * @return the result of dispatching the method represented by
 564      * this object on {@code obj} with parameters
 565      * {@code args}
 566      *
 567      * @exception IllegalAccessException    if this {@code Method} object
 568      *              is enforcing Java language access control and the underlying
 569      *              method is inaccessible.
 570      * @exception IllegalArgumentException  if the method is an
 571      *              instance method and the specified object argument
 572      *              is not an instance of the class or interface
 573      *              declaring the underlying method (or of a subclass
 574      *              or implementor thereof); if the number of actual
 575      *              and formal parameters differ; if an unwrapping
 576      *              conversion for primitive arguments fails; or if,
 577      *              after possible unwrapping, a parameter value
 578      *              cannot be converted to the corresponding formal
 579      *              parameter type by a method invocation conversion.
 580      * @exception InvocationTargetException if the underlying method
 581      *              throws an exception.
 582      * @exception NullPointerException      if the specified object is null
 583      *              and the method is an instance method.
 584      * @exception ExceptionInInitializerError if the initialization
 585      * provoked by this method fails.
 586      */
 587     public Object invoke(Object obj, Object... args)
 588         throws IllegalAccessException, IllegalArgumentException,