Java enums over IIOP

Posted Sun, 17 Feb 2008 18:42:00 GMT

If you pass an enum argument over IIOP, the value in the deserialised object on the server has very strange properties. Here’s what I observed (someEnum is the deserialised object on the server):

someEnum = null
someEnum.name() = null
someEnum.toString() = null
(someEnum == null) = false

Clearly a fairly useless instance for any possible purpose. It’s null, but not quite. It has no value and can not be meaningfully compared.

You can’t work around it with Externalizable, because the immutable enum can not modify itself, and for the same (perfectly valid) reason write/readObject are useless.

This was reported in May 2005 - here - http://bugs.sun.com/bugdatabase/viewbug.do?bugid=6277781

The last comment on that entry, made in Aug 2007 says: “btw, is someone working on that?…”.

Seems either people who use Java 5 and later do not use IIOP and vice versa, or you’d have thought someone would have done something by now….

Any super-clever ideas for a workaround are most welcome.

“Don’t use enums” and “don’t use IIOP” do not count as super-clever on this occasion.

Comments

Trackbacks

Use the following link to trackback from your own site:
http://supplesoftware.com/articles/trackback/60

(leave url/email »)

  

Home

Who's George?

Recent entries