protected Object readObjectImpl(Class cl) throws IOException {
  try {
    Object obj=cl.newInstance();
    if (_refs == null)     _refs=new ArrayList();
    _refs.add(obj);
    HashMap fieldMap=getFieldMap(cl);
    int code=read();
    for (; code >= 0 && code != 'z'; code=read()) {
      unread();
      Object key=readObject();
      Field field=(Field)fieldMap.get(key);
      if (field != null) {
        Object value=readObject(field.getType());
        field.set(obj,value);
      }
 else {
        Object value=readObject();
      }
    }
    if (code != 'z')     throw expect("map",code);
    try {
      Method method=cl.getMethod("readResolve",new Class[0]);
      return method.invoke(obj,new Object[0]);
    }
 catch (    Exception e) {
    }
    return obj;
  }
 catch (  IOException e) {
    throw e;
  }
catch (  Exception e) {
    throw new IOExceptionWrapper(e);
  }
}

protected Object readObjectImpl ( Class cl ) throws IOException { try { Object obj = cl . newInstance ( ) ; if ( _refs == null ) _refs = new ArrayList ( ) ; _refs . add ( obj ) ; HashMap fieldMap = getFieldMap ( cl ) ; int code = read ( ) ; for ( ; code >= 0 && code != 'z' ; code = read ( ) ) { unread ( ) ; Object key = readObject ( ) ; Field field = ( Field ) fieldMap . get ( key ) ; if ( field != null ) { Object value = readObject ( field . getType ( ) ) ; field . set ( obj , value ) ; } else { Object value = readObject ( ) ; } } if ( code != 'z' ) throw expect ( "map" , code ) ; try { Method method = cl . getMethod ( "readResolve" , new Class [ 0 ] ) ; return method . invoke ( obj , new Object [ 0 ] ) ; } catch ( Exception e ) { } return obj ; } catch ( IOException e ) { throw e ; } catch ( Exception e ) { throw new IOExceptionWrapper ( e ) ; } }
reads an object from the input stream . cl is known not to be a map .
