Drag action throwing exceptions on Mac

I’m using JGo 5.0 in our application. I have some node objects on
a JGoView and when users drag the nodes around on Windows, everything
works beautifully. However, on the Mac, the action of dragging a
node causes the following exception to be thrown:

java.io.NotSerializableException:

edu.stanford.smi.protegex.widget.graph.GraphDocument$1 at

java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.j ava:1054)

etc…

Is this a known problem on the Mac?

Thank you

That looks like the name of an anonymous class defined in your GraphDocument class. You’d have to look at it to try to figure out what that might be, and then see why it’s being serialized.

Hi Walter,

Thank you for your reply. I’m not doing any serialization in my
anonymous class. I’ve discovered that there’s a bug in Apple’s
java code that causes unnecessary serialization during drag and
drop. In case anyone else reports this behavior, the bug is described on developer.apple.com and is supposedly fixed in “Update 2” of their JDK 1.4.2 release (although I haven’t tested it yet).

Jennifer

Actually, drag-and-drop can require doing serialization and deserialization. I’m guessing that the case you have encountered could be optimized not to do such serialization and deserialization, but in the general case that needs to work.
The same is true for copyToClipboard and pasteFromClipboard, although serialization I think should always be necessary, since a copy must be made.

I’m using java version “1.5.0_07” on Mac OSX 10.4 and JGo 5.1, and I still have this NotSerializableException, when I release the mouse button in a JGoView. Is there any bright minds out there, that has a solution on this?

Does this error occur when dragging a standard JGo object or does it only occur when dragging a JGo subclass that you have created?

All your JGoObject-derived classes need to be serializable. That means that all of the fields you add need to be serializable or transient.

It is a JGoComponent derived class, but it has some swing components inside, which are not serializable :( On the windows platform are writeObject not called, when dragging a component. Has Apple implemented the Java WM using different paint() strategies? And why?

I don’t know how Apple has implemented their Java VM, but I do know that all JGoObjects that are dragged and dropped need to be serializable, regardless of platform. In your derived object class, try declaring as transient any field that is not serializable. This should at least allow the drag and drop to take place and confirm that this is the problem.