/** * Reads and returns a class annotation string value (possibly <code>null</code>) that was * written by a corresponding <code>AnnotatedObjectOutputStream</code> implementation. * * <p><code>AnnotatedObjectInputStream</code> implements this method to just read the annotation * value from this stream using {@link ObjectInputStream#readUnshared readUnshared}, and if * <code>readUnshared</code> returns a non-<code>null</code> value that is not a * <code>String</code>, an {@link InvalidObjectException} is thrown. * * <p>A subclass can override this method to read the annotation from a different location. * * @return the class annotation string value read (possibly <code>null</code>) * @throws IOException if an I/O exception occurs reading the annotation * @throws ClassNotFoundException if a <code>ClassNotFoundException</code> occurs reading the * annotation **/ protected String readAnnotation(ObjectStreamClass desc) throws IOException, ClassNotFoundException { try { return (String) readUnshared(); } catch (ClassCastException e) { InvalidObjectException ioe = new InvalidObjectException("Annotation is not String or null"); ioe.initCause(e); throw ioe; } }
public void readExternal(AnnotatedObjectInputStream in) throws IOException, ClassNotFoundException { if (in.readByte() != SERIAL_VERSION) throw new UnmarshalException("Requested version does not match local version. Please make sure you are using the same version on both ends."); LRMIRemoteClassLoaderIdentifier remoteClassLoaderId = RemoteClassLoaderContext.get(); LRMIRemoteClassLoaderIdentifier previousIdentifier = null; if (remoteClassLoaderId != null) previousIdentifier = LRMIConnection.setRemoteClassLoaderIdentifier(remoteClassLoaderId); result = (T) in.readUnshared(); exception = (Exception) in.readUnshared(); if (remoteClassLoaderId != null) LRMIConnection.setRemoteClassLoaderIdentifier(previousIdentifier); }