protected ClassMapping readClassMapping ( ) throws IOException , ClassNotFoundException { // create our classmap if necessary if ( _classmap == null ) { _classmap = Lists . newArrayList ( ) ; // insert a zeroth element _classmap . add ( null ) ; } // read in the class code for this instance short code = readShort ( ) ; // a zero code indicates a null value if ( code == 0 ) { return null ; // if the code is negative, that means that we've never seen it before and class // metadata follows } else if ( code < 0 ) { // first swap the code into positive-land code *= - 1 ; // read in the class metadata String cname = readUTF ( ) ; // if we have a translation (used to cope when serialized classes are renamed) use // it if ( _translations != null ) { String tname = _translations . get ( cname ) ; if ( tname != null ) { cname = tname ; } } // create the class mapping return mapClass ( code , cname ) ; } else { ClassMapping cmap = ( code < _classmap . size ( ) ) ? _classmap . get ( code ) : null ; // sanity check if ( cmap == null ) { // this will help with debugging log . warning ( "Internal stream error, no class metadata" , "code" , code , "ois" , this , new Exception ( ) ) ; log . warning ( "ObjectInputStream mappings" , "map" , _classmap ) ; String errmsg = "Read object code for which we have no registered class " + "metadata [code=" + code + "]" ; throw new RuntimeException ( errmsg ) ; } return cmap ; } }
Reads a class mapping from the stream .