The context:
> I have a serializable class.  It has 3 attributes.  When deserialized on the other 
> end of an RMI connection, 2 of the attributes are intact, one is null.  The one that 
> is lost is a typesafe enum (al la Bloch) and a static inner class.
> 
I'm assuming that either:
(a) I'm simply ignorant of something obvious and stupid (e.g., a private instance 
variable with a name ending in "e" is implicitly transient), or
(b) There is something clever and subtle about the combination of serialization, 
typesafe enums and static inner classes.

Either way, if anyone out there has fallen into this same pit, I'd appreciate a word 
of wisdom about now.

Thanks,
Ken

P.S.
Sample code follows... 

> public class OperationResult implements Serializable {
        // constants
>       public static final Code EXCEPTION = new Code(0,"Exception");
>       public static final Code FILTER_DENY = new Code(1,"Filter Deny");
>       public static final Code NOT_EMPTY = new Code(2,"Not Empty");
> 
        // attributes
        private String myPathUrlStr;    // works fine
>       private Code myCode;            // is always null on deserialization!
>       private Exception myException;  // works fine
>       :
        // getters, toString and such
>       :
        // typesafe enum inner class
>       public static final class Code implements Serializable {
> 
>               private static final Code[] PRIVATE_VALUES = { EXCEPTION, FILTER_DENY, 
> NOT_EMPTY };
> 
>               private final int myIndex;
>               private final String myValue;
                :
                :
>               private Object readResolve() throws java.io.ObjectStreamException {
>                               Object retVal = PRIVATE_VALUES[myIndex]; 
>                               return retVal;
>               }
>       }
> }
> 
> 

_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to