Code example for InvalidObjectException

0
    public final Object readResolve() throws ObjectStreamException {
        // This code ensures that only one instance of a given class and state 
        // value can ever exist per JVM instance. 
        WMObjectState obj = getValues()[_state];
        if (obj == null) {
            throw new InvalidObjectException("Invalid code in object stream: "
                + _state);
        } 
        return obj;
    } 
 
    /** 
     * Returns the object state as a string. 
     * @return The object state. 
     */ 
    public final String stringValue() {
        return getTags()[_state];
    } 
 
    public final String toString() {
//        String clazz = getClass().getName();