public class UnicastRemoteObject
  Comment     Returned-by     Constructor-argument     Method-argument     Field-type     Type-bound     Links  

Used for exporting a remote object with JRMP and obtaining a stub that communicates to the remote object. Stubs are either generated at runtime using dynamic proxy objects, or they are generated statically at build time, typically using the rmic tool.

Deprecated: Static Stubs. Support for statically generated stubs is deprecated. This includes the API in this class that requires the use of static stubs, as well as the runtime support for loading static stubs. Generating stubs dynamically is preferred, using one of the five non-deprecated ways of exporting objects as listed below. Do not run rmic to generate static stub classes. It is unnecessary, and it is also deprecated.

There are six ways to export remote objects:

  1. Subclassing UnicastRemoteObject and calling the UnicastRemoteObject() constructor.
  2. Subclassing UnicastRemoteObject and calling the UnicastRemoteObject(port) constructor.
  3. Subclassing UnicastRemoteObject and calling the UnicastRemoteObject(int, RMIClientSocketFactory, RMIServerSocketFactory) constructor.
  4. Calling the exportObject(Remote) method. Deprecated.
  5. Calling the exportObject(Remote, port) method.
  6. Calling the exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory) method.

The fourth technique, exportObject(Remote), always uses statically generated stubs and is deprecated.

The other five techniques all use the following approach: if the java.rmi.server.ignoreStubClasses property is true (case insensitive) or if a static stub cannot be found, stubs are generated dynamically using Proxy objects. Otherwise, static stubs are used.

The default value of the java.rmi.server.ignoreStubClasses property is false.

Statically generated stubs are typically pregenerated from the remote object's class using the rmic tool. A static stub is loaded and an instance of that stub class is constructed as described below.

Stubs are dynamically generated by constructing an instance of a Proxy with the following characteristics:

extends RemoteServer

Since:  JDK1.1

@implNote Depending upon which constructor or static method is used for exporting an object, RMISocketFactory may be used for creating sockets. By default, server sockets created by RMISocketFactory listen on all network interfaces. See the RMISocketFactory class and the section RMI Socket Factories in the Java RMI Specification.