public MarshalledValue(Object obj) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(baos); mvos.writeObject(obj); mvos.flush(); serializedForm = baos.toByteArray(); mvos.close(); // Use the java.rmi.MarshalledObject hash code calculation int hash = 0; for (int i = 0; i < serializedForm.length; i++) { hash = 31 * hash + serializedForm[i]; } hashCode = hash; }