getPort() question

From: Shin, Sang <>
Date: Fri, 29 Mar 2002 14:24:06 -0700

In the API spec, the getPort() method is described as following:

   public java.rmi.Remote getPort(java.lang.Class serviceDefInterface)
   The getPort method Returns either an instance of a generated stub implementation class or a dynamic proxy.
          The parameter serviceDefInterface specifies the service definitiojava.lang.reflect.Proxyn interface that is
          supported by the returned stub or proxy. In the implementation of this method, the JAX-RPC runtime system
          takes the responsibility of selecting a protocol binding (and a port) and configuring the stub accordingly. The
          returned Stub instance should not be reconfigured by the client.

So it seems this method can return either stub implementation or dynamic
proxy. My question is how does JAX-RPC runtime decide which one
to return? Thanks