What is the cleanest way to design methods of remote objects that may return null? Normally, I let the method return null, and the code that calls the method checks for null before using the object that was returned. Unfortunately, this doesn't work with RMI, as if (obj == null) returns false, because the obj references a valid stub which references null.
We are not sure we understand the question.
RemoteServer rs ...
String back = null;
back = rs.getName();
// here, when the remote method getName returns null, back is still null
if (back == null)
You would not test "rs" since this is the reference to the Remote Object, "RemoteServer". Therefore, the "cleanest" way is the most direct way.