Logo Search packages:      
Sourcecode: jamvm version File versions

Object java::lang::reflect::Method::invoke ( Object  o,
Object[]  args 
) throws IllegalAccessException, InvocationTargetException [inline]

Invoke the method. Arguments are automatically unwrapped and widened, and the result is automatically wrapped, if needed.

If the method is static, o will be ignored. Otherwise, the method uses dynamic lookup as described in JLS 15.12.4.4. You cannot mimic the behavior of nonvirtual lookup (as in super.foo()). This means you will get a NullPointerException if o is null, and an IllegalArgumentException if it is incompatible with the declaring class of the method. If the method takes 0 arguments, you may use null or a 0-length array for args.

Next, if this Method enforces access control, your runtime context is evaluated, and you may have an IllegalAccessException if you could not acces this method in similar compiled code. If the method is static, and its class is uninitialized, you trigger class initialization, which may end in a ExceptionInInitializerError.

Finally, the method is invoked. If it completes normally, the return value will be null for a void method, a wrapped object for a primitive return method, or the actual return of an Object method. If it completes abruptly, the exception is wrapped in an InvocationTargetException.

Parameters:
o the object to invoke the method on
args the arguments to the method
Returns:
the return value of the method, wrapped in the appropriate wrapper if it is primitive
Exceptions:
IllegalAccessException if the method could not normally be called by the Java code (i.e. it is not public)
IllegalArgumentException if the number of arguments is incorrect; if the arguments types are wrong even with a widening conversion; or if o is not an instance of the class or interface declaring this method
InvocationTargetException if the method throws an exception
NullPointerException if o is null and this field requires an instance
ExceptionInInitializerError if accessing a static method triggered class initialization, which then failed

Definition at line 303 of file Method.java.

  {
    return invokeNative(o, args, declaringClass, parameterTypes, returnType, slot);
  }


Generated by  Doxygen 1.6.0   Back to index