Hi, While playing a bit with Cajo (http://wiki.java.net/bin/view/Communications/ProxyUsage) I got the following error:
java.lang.NullPointerException at gnu.cajo.invoke.Remote.hashCode (Remote.java:510) at java.util.Hashtable.hash (Hashtable.java:822) at java.util.Hashtable.put (Hashtable.java:432) at gnu.java.rmi.server.UnicastServer.exportObject (UnicastServer.java:66) at gnu.java.rmi.server.UnicastServerRef.exportObject (UnicastServerRef.java:110) at java.rmi.server.UnicastRemoteObject.exportObject (UnicastRemoteObject.java:83) at java.rmi.server.UnicastRemoteObject.<init> (UnicastRemoteObject.java:69) at gnu.cajo.invoke.Remote.<init> (Remote.java:486) at gnu.cajo.utils.ItemServer.bind (ItemServer.java:206) at ProxyTest.main (ProxyTest.java:38) It seems we are to eager to export the Remote object immediately (from the constructor). We want to put it in a Hashtable and call hasCode(), but for the cajo Remote object the item field used to calculate the hashCode() hasn't been set yet so that gives a NullPointerException. Looking at the code I think we might actually want a IdentityHashMap here that uses the System.identityHashCode() for an object since we are not really interested in equal objects here. With the attached patch I get a little further, but then hit the following error (on the server side): java.io.IOException: bad protocol header at gnu.java.rmi.server.UnicastConnection.acceptConnection (UnicastConnection.java:79) at gnu.java.rmi.server.UnicastConnectionManager.getServerConnection (UnicastConnectionManager.java:265) at gnu.java.rmi.server.UnicastConnectionManager.run (UnicastConnectionManager.java:371) at java.lang.Thread.run (Thread.java:673) I didn't found time to investigate this further, but I wanted to post the patch that I used in case someone else had some time to investigate our rmi implementation a bit more. Cheers, Mark
Index: gnu/java/rmi/server/UnicastServer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/rmi/server/UnicastServer.java,v
retrieving revision 1.9
diff -u -r1.9 UnicastServer.java
--- gnu/java/rmi/server/UnicastServer.java 2 Jul 2005 20:32:14 -0000 1.9
+++ gnu/java/rmi/server/UnicastServer.java 11 Sep 2005 19:37:57 -0000
@@ -51,13 +51,16 @@
import java.rmi.ServerError;
import java.rmi.server.ObjID;
import java.rmi.server.UID;
+import java.util.Collections;
+import java.util.Map;
import java.util.Hashtable;
+import java.util.IdentityHashMap;
public class UnicastServer
implements ProtocolConstants {
static private Hashtable objects = new Hashtable(); //mapping OBJID to server ref
-static private Hashtable refcache = new Hashtable(); //mapping obj itself to server ref
+static private Map refcache = Collections.synchronizedMap(new IdentityHashMap()); //mapping obj itself to server ref
static private DGCImpl dgc;
public static void exportObject(UnicastServerRef obj) {
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath

