users@glassfish.java.net

Can't deserialize enum

From: Joe Jordan <joe.glassfish_at_psychlaw.com.au>
Date: Mon, 21 Jul 2008 12:09:30 +1000

Heya folks,

We are trying to upgrade from JDK 1.5.0_09 to 1.5.0_16 due to JVM
crashes, but it appears enum serialization was totally broken in JDK
1.5.0_14.

The errors we are getting are:

Caused by: java.io.InvalidObjectException: can't deserialize enum
        at java.lang.Enum.readObject(Enum.java:205)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
        at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
com
.sun
.corba
.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:
1679)

We get these errors both on Glassfish 9.0_01 and 9.1_01. We also get
the same problem with JDK 1.6.0_07.

We are familiar with https://glassfish.dev.java.net/issues/show_bug.cgi?id=193
  and have been working around this problem (enums don't preserve
reference equality over RMI/IIOP) for years now. The comments seem to
suggest the issue is resolved in "GFv2 b40", but I am fairly sure the
version we are on (9.1ur1bSomething) is later than this?

Issue #193 also provides a link to a non-existent Glassfish issue at https://glassfish.dev.java.net/issues/show_bug.cgi?id=10336
  (looks like the link should be to OMG, wherever that is).

Does anyone know a workaround/solution to this issue that does not
involve adding custom writeReplace() serialization logic to all of our
enums?

Cheers,
Joe