By default, all threads in the target VM are resumed while the method is being invoked if they were previously suspended by an event or by {@link VirtualMachine#suspend} or{@link ThreadReference#suspend}. This is done to prevent the deadlocks that will occur if any of the threads own monitors that will be needed by the invoked method. Note, however, that this implicit resume acts exactly like {@link ThreadReference#resume}, so if the thread's suspend count is greater than 1, it will remain in a suspended state during the invocation and thus a deadlock could still occur. By default, when the invocation completes, all threads in the target VM are suspended, regardless their state before the invocation. It is possible that breakpoints or other events might occur during the invocation. This can cause deadlocks as described above. It can also cause a deadlock if invokeMethod is called from the client's event handler thread. In this case, this thread will be waiting for the invokeMethod to complete and won't read the EventSet that comes in for the new event. If this new EventSet is SUSPEND_ALL, then a deadlock will occur because no one will resume the EventSet. To avoid this, all EventRequests should be disabled before doing the invokeMethod, or the invokeMethod should not be done from the client's event handler thread.
The resumption of other threads during the invocation can be prevented by specifying the {@link #INVOKE_SINGLE_THREADED}bit flag in the options
argument; however, there is no protection against or recovery from the deadlocks described above, so this option should be used with great caution. Only the specified thread will be resumed (as described for all threads above). Upon completion of a single threaded invoke, the invoking thread will be suspended once again. Note that any threads started during the single threaded invocation will not be suspended when the invocation completes.
If the target VM is disconnected during the invoke (for example, through {@link VirtualMachine#dispose}) the method invocation continues. @param thread the thread in which to invoke. @param method the {@link Method} to invoke. @param arguments the list of {@link Value} arguments bound to theinvoked method. Values from the list are assigned to arguments in the order they appear in the method signature. @param options the integer bit flag options. @return a {@link Value} mirror of the invoked method's return value. @throws java.lang.IllegalArgumentException if the method is nota member of this class or a superclass, if the size of the argument list does not match the number of declared arguemnts for the method, or if the method is an initializer, constructor or static intializer. @throws {@link InvalidTypeException} if any argument in theargument list is not assignable to the corresponding method argument type. @throws ClassNotLoadedException if any argument type has not yet been loadedthrough the appropriate class loader. @throws IncompatibleThreadStateException if the specified thread has notbeen suspended by an event. @throws InvocationException if the method invocation resulted inan exception in the target VM. @throws InvalidTypeException If the arguments do not meet this requirement --Object arguments must be assignment compatible with the argument type. This implies that the argument type must be loaded through the enclosing class's class loader. Primitive arguments must be either assignment compatible with the argument type or must be convertible to the argument type without loss of information. See JLS section 5.2 for more information on assignment compatibility. @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
By default, the method is invoked using dynamic lookup as documented in the Java Language Specification second edition, section 15.12.4.4; in particular, overriding based on the runtime type of the object mirrored by this {@link ObjectReference} will occur. Thisbehavior can be changed by specifying the {@link #INVOKE_NONVIRTUAL} bit flag in the options
argument. If this flag is set, the specified method is invoked whether or not it is overridden for this object's runtime type. The method, in this case, must not belong to an interface and must not be abstract. This option is useful for performing method invocations like those done with the super
keyword in the Java programming language.
By default, all threads in the target VM are resumed while the method is being invoked if they were previously suspended by an event or by {@link VirtualMachine#suspend} or{@link ThreadReference#suspend}. This is done to prevent the deadlocks that will occur if any of the threads own monitors that will be needed by the invoked method. Note, however, that this implicit resume acts exactly like {@link ThreadReference#resume}, so if the thread's suspend count is greater than 1, it will remain in a suspended state during the invocation and thus a deadlock could still occur. By default, when the invocation completes, all threads in the target VM are suspended, regardless their state before the invocation. It is possible that breakpoints or other events might occur during the invocation. This can cause deadlocks as described above. It can also cause a deadlock if invokeMethod is called from the client's event handler thread. In this case, this thread will be waiting for the invokeMethod to complete and won't read the EventSet that comes in for the new event. If this new EventSet is SUSPEND_ALL, then a deadlock will occur because no one will resume the EventSet. To avoid this, all EventRequests should be disabled before doing the invokeMethod, or the invokeMethod should not be done from the client's event handler thread.
The resumption of other threads during the invocation can be prevented by specifying the {@link #INVOKE_SINGLE_THREADED}bit flag in the options
argument; however, there is no protection against or recovery from the deadlocks described above, so this option should be used with great caution. Only the specified thread will be resumed (as described for all threads above). Upon completion of a single threaded invoke, the invoking thread will be suspended once again. Note that any threads started during the single threaded invocation will not be suspended when the invocation completes.
If the target VM is disconnected during the invoke (for example, through {@link VirtualMachine#dispose}) the method invocation continues. @param thread the thread in which to invoke. @param method the {@link Method} to invoke. @param arguments the list of {@link Value} arguments bound to theinvoked method. Values from the list are assigned to arguments in the order they appear in the method signature. @param options the integer bit flag options. @return a {@link Value} mirror of the invoked method's return value. @throws java.lang.IllegalArgumentException if the method is nota member of this object's class, if the size of the argument list does not match the number of declared arguemnts for the method, if the method is a constructor or static intializer, or if {@link #INVOKE_NONVIRTUAL} is specified and the method iseither abstract or an interface member. @throws {@link InvalidTypeException} if any argument in theargument list is not assignable to the corresponding method argument type. @throws ClassNotLoadedException if any argument type has not yet been loadedthrough the appropriate class loader. @throws IncompatibleThreadStateException if the specified thread has notbeen suspended by an event. @throws InvocationException if the method invocation resulted inan exception in the target VM. @throws InvalidTypeException If the arguments do not meet this requirement --Object arguments must be assignment compatible with the argument type. This implies that the argument type must be loaded through the enclosing class's class loader. Primitive arguments must be either assignment compatible with the argument type or must be convertible to the argument type without loss of information. See JLS section 5.2 for more information on assignment compatibility. @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
Invokes a method on the given receiver for the specified arguments. The sender is the class that invoked the method on the object. The MetaClass will attempt to establish the method to invoke based on the name and arguments provided.
The isCallToSuper and fromInsideClass help the Groovy runtime perform optimisations on the call to go directly to the super class if necessary @param sender The java.lang.Class instance that invoked the method @param receiver The object which the method was invoked on @param methodName The name of the method @param arguments The arguments to the method @param isCallToSuper Whether the method is a call to a super class method @param fromInsideClass Whether the call was invoked from the inside or the outside of the class @return The return value of the method
method_name
method is void, null
is returned.method_name
method returns a primitive type, then return wrapper class instance.
@throws InvocationTargetException when the invoked method throws an exception.
@throws NoSuchMethodException when the method cannot be found.
@throws IllegalAccessException when access to the class or method is lacking.
@throws SecurityException if access to the package or method is denied.
@exception IllegalAccessException
@exception NoSuchMethodException
@exception InvocationTargetException
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|