Class RemoteObjectInvocationHandler
- All Implemented Interfaces:
Serializable, InvocationHandler, Remote
public class RemoteObjectInvocationHandler extends RemoteObject implements InvocationHandler
InvocationHandler interface for use with Java Remote Method Invocation (Java RMI). This invocation handler can be used in conjunction with a dynamic proxy instance as a replacement for a pregenerated stub class. Applications are not expected to use this class directly. A remote object exported to use a dynamic proxy with UnicastRemoteObject has an instance of this class as that proxy's invocation handler.
- Since:
- 1.5
- See Also:
Field Summary
Fields declared in class RemoteObject
ref | Modifier and Type | Field | Description |
|---|---|---|
protected RemoteRef |
ref |
The object's remote reference. |
Constructor Summary
| Constructor | Description |
|---|---|
RemoteObjectInvocationHandler |
Creates a new RemoteObjectInvocationHandler constructed with the specified RemoteRef. |
Method Summary
Methods declared in class RemoteObject
equals, getRef, hashCode, toString, toStub | Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals |
Compares two remote objects for equality. |
RemoteRef |
getRef() |
Returns the remote reference for the remote object. |
int |
hashCode() |
Returns a hashcode for a remote object. |
String |
toString() |
Returns a String that represents the value of this remote object. |
static Remote |
toStub |
Returns the stub for the remote object obj passed as a parameter. |
Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
RemoteObjectInvocationHandler
public RemoteObjectInvocationHandler(RemoteRef ref)
RemoteObjectInvocationHandler constructed with the specified RemoteRef.- Parameters:
-
ref- the remote ref - Throws:
-
NullPointerException- ifrefisnull
Method Details
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
proxy, and returns the result. RemoteObjectInvocationHandler implements this method as follows:
If method is one of the following methods, it is processed as described below:
-
Object.hashCode: Returns the hash code value for the proxy. -
Object.equals: Returnstrueif the argument (args[0]) is an instance of a dynamic proxy class and this invocation handler is equal to the invocation handler of that argument, and returnsfalseotherwise. -
Object.toString: Returns a string representation of the proxy.
If method overrides Object.finalize, it is ignored.
Otherwise, a remote call is made as follows:
- If
proxyis not an instance of the interfaceRemote, then anIllegalArgumentExceptionis thrown. - Otherwise, the
invokemethod is invoked on this invocation handler'sRemoteRef, passingproxy,method,args, and the method hash (defined in section 8.3 of the "Java Remote Method Invocation (RMI) Specification") formethod, and the result is returned. - If an exception is thrown by
RemoteRef.invokeand that exception is a checked exception that is not assignable to any exception in thethrowsclause of the method implemented by theproxy's class, then that exception is wrapped in anUnexpectedExceptionand the wrapped exception is thrown. Otherwise, the exception thrown byinvokeis thrown by this method.
The semantics of this method are unspecified if the arguments could not have been produced by an instance of some valid dynamic proxy class containing this invocation handler.
- Specified by:
-
invokein interfaceInvocationHandler - Parameters:
-
proxy- the proxy instance that the method was invoked on -
method- theMethodinstance corresponding to the interface method invoked on the proxy instance -
args- an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, ornullif the method takes no arguments - Returns:
- the value to return from the method invocation on the proxy instance
- Throws:
-
Throwable- the exception to throw from the method invocation on the proxy instance - See Also:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.