title: RMI and references / Proxy classes
body: <p>As far as I can see, given a <code>IFoo</code> interface extending <code>Remote</code> and a <code>FooImpl</code> class implementing <code>IFoo</code>,  the following two code fragments are (almost) equivalent : (1)</p>
  
  <pre><code>IFoo stub = ( IFoo )UnicastRemoteObject.exportObject( new FooImpl() );
  Naming.bind( "foo", stub );
  </code></pre>
  
  <p>and, if <code>FooImpl</code> is a class that extends <code>UnicastRemoteObject</code> : (2)</p>
  
  <pre><code>Naming.bind( "foo", new FooImpl() );
  </code></pre>
  
  <p>In fact, the <code>FooImpl</code> instance exportation is done in the implicit <code>UnicastRemoteObject</code> constructor call.</p>
  
  <p>But in (1), the object returned by <code>UnicastRemoteObject.exportObject()</code> is a <code>Proxy</code> (dynamic) class, and consequently the object recorded in the RMI registry is obviously a reference. Whereas in (2), it is not clear. </p>
  
  <p>Where is the <code>Proxy</code> construction based an a <code>FooImpl</code> instance realized ? I have seen that the RMI registry management in the client code (<code>Naming.bind()</code>) encapsulates a (registry) <code>Proxy</code> class creation with a call to <code>LocateRegistry.getRegister()</code>. So in the request :</p>
  
  <pre><code>Naming.bind( "foo", new FooImpl() )
  </code></pre>
  
  <p>is it the registry <code>Proxy</code> class invocation handler that handles the parameters extending <code>Remote</code> to transform them as references / <code>Proxy</code> classes ?</p>
  
  <p>And in that case, given that the stub <code>Proxy</code> class in (1) is itself a <code>Remote</code> class, would that mean that the object stored in the registry is a reference to a reference (i.e. a <code>Proxy</code> calling another <code>Proxy</code> calling the real class) ? </p>
  
  <p>Thanks.</p>