ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer); ObjectInputStream in=new ContextObjectInputStream(in_stream); retval=in.readObject(); in.close();
try { ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer); ObjectInputStream in=new ContextObjectInputStream(in_stream); retval=in.readObject(); in.close(); } catch(StreamCorruptedException sce) { try { ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer); DataInputStream in=new DataInputStream(in_stream); retval=readGenericStreamable(in); in.close(); } catch(Exception ee) { IOException tmp=new IOException("unmarshalling failed"); tmp.initCause(ee); throw tmp; } }
    public static Object objectFromByteBuffer(byte[] buffer) throws Exception {        synchronized(mutex) {            if(buffer == null) return null;            Object retval=null;            ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer);            ObjectInputStream in=new ContextObjectInputStream(in_stream); // changed Nov 29 2004 (bela)            retval=in.readObject();            in.close();            if(retval == null)                return null;            return retval;        }    }