Ah, a challenge! I accept!
Challenges only help you refine your knowledge/beliefs. I'm gonna try to do my research on this one, so hold on, this may get crazy!
To begin with, the poster on JGuru is wrong. Here's the what the
java docs say about the unreferenced() method.
Called by the RMI runtime sometime after the runtime determines that the reference list, the list of clients referencing the remote object, becomes empty.
Since the registry is not a client, this method could be called any time there is no one connected. In addition to this, if there are no local references when the unreferenced() method is called, your server gets GC'd.
Now, about the registry. It CAN'T hold a true reference to your server. References can only be held by objects operating in the same JVM. One way to run the registry is by starting it up from the JRE directories with a command line. But that would start it up in its own JVM, separate from your program's JVM. Thus, the registry can't be holding a true reference.
I don't have the whole picture yet, but here is what I have gathered so far. Your server most likely extends UnicastRemoteObject. When a URO is instantiated, it exports itself somehow to be made available remotely through the RMI run-time system (this is not the registry, that comes later ). So any class that is coded to be aware of the RMI run-time system can actually return a link to your server through RMI. But I think it must be running on your local machine so that it can be aware of the local RMI situation. Now, the registry is one way to access the RMI info. There are others, and in fact, once you have access to the server itself, it can actually serve as a reference to other servers that might also be living on the same machine. Not sure exactly how that works, but i might try it some time.
Back to the registry. While it doesn't hold a true reference to your server, it does hold a flat name key(there's no structure -file,web,nothing- its just a string) that it matches to a reference in the RMI system. This key is what you reference when you do a Naming.lookup() in your client. The RMI refence returned by a lookup can then be accessed directly by the client without going through the registry.
Whew its getting late. I've been researching this for about 3 hours. I hope I've made at least a little sense. Please ask questions if you have them. I learn a whole lot more about how things work when I have to explain them to others.
Chris