7.11.1. Interface

The interface of a remotely accessible object is a standard Java interface, with several simple restrictions. A remotely accessible object must implement the Remote interface, which marks it as an object that can receive remote invocations. All remotely accessible methods must be able to throw the RemoteException exception. Only serializable types can be passed by value.

public interface Example extends Remote
{
    void printMessage (String message) throws RemoteException;
}

The stubs are instances of the generic Proxy class that appear to implement all Remote interfaces of the server implementation. It is possible to cast between multiple remote interfaces of the same remote object. The stubs implement the equals and hashCode methods, making proxies that refer to the same remote object appear equal.