Class AnnotatedObjectInputStream
- All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable
- Direct Known Subclasses:
MarshalInputStream
ObjectInputStream that implements the dynamic class loading
semantics of RMI argument and result unmarshalling (using RMIClassLoader). A
AnnotatedObjectInputStream is intended to read data written by a corresponding
AnnotatedObjectOutputStream.
AnnotatedObjectInputStream implements the input side of the dynamic class loading
semantics by overriding resolveClass and resolveProxyClass to resolve class descriptors in the stream
using
invalid reference
ClassLoading.loadClassinvalid reference
ClassLoading.loadProxyClassRMIClassLoader.loadClass and RMIClassLoader.loadProxyClass),
optionally with CodeBase annotation strings written by a AnnotatedObjectOutputStream.
AnnotatedObjectInputStream reads class annotations from its own stream; a
subclass can override the readAnnotation method to read the class
annotations from a different location.
A AnnotatedObjectInputStream is not guaranteed to be safe for concurrent use by
multiple threads.
- Since:
- 5.1
- Author:
- Igor Goldenberg, anna
-
Nested Class Summary
Nested classes/interfaces inherited from class ObjectInputStream
ObjectInputStream.GetField -
Field Summary
Fields inherited from interface ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAnnotatedObjectInputStreamthat reads marshalled data from the specified underlyingInputStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReads and returns a class annotation string value (possiblynull) that was written by a correspondingAnnotatedObjectOutputStreamimplementation.protected ClassresolveClass(ObjectStreamClass classDesc) protected ClassresolveClass(ObjectStreamClass classDesc, boolean readAnnotation, String codebase) Resolves the appropriateClassobject for the stream class descriptorclassDesc.Methods inherited from class ObjectInputStream
available, close, defaultReadObject, enableResolveObject, getObjectInputFilter, read, read, readBoolean, readByte, readChar, readClassDescriptor, readDouble, readFields, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readObjectOverride, readShort, readStreamHeader, readUnshared, readUnsignedByte, readUnsignedShort, readUTF, registerValidation, resolveObject, resolveProxyClass, setObjectInputFilter, skipBytesMethods inherited from class InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferToMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ObjectInput
read, skip
-
Constructor Details
-
AnnotatedObjectInputStream
Creates a newAnnotatedObjectInputStreamthat reads marshalled data from the specified underlyingInputStream.This constructor passes
into the superclass constructor that has anInputStreamparameter.defaultLoaderwill be passed as thedefaultLoaderargument toandinvalid reference
ClassLoading.loadClasswhenever those methods are invoked byinvalid reference
ClassLoading.loadProxyClassresolveClassandresolveProxyClass.If
verifyCodebaseIntegrityistrue, then the created stream will verify that all codebase annotation URLs that are used to load classes resolved by the stream provide content integrity, and wheneveris invoked to enforce that verification,invalid reference
Security.verifyCodebaseIntegrityverifierLoaderwill be passed as theloaderargument. Seeandinvalid reference
ClassLoading.loadClassfor details of how codebase integrity verification is performed.invalid reference
ClassLoading.loadProxyClasscontextwill be used as the return value of the created stream'smethod.invalid reference
getObjectStreamContext- Parameters:
in- the input stream to read marshalled data fromdefaultLoader- the class loader value (possiblynull) to pass as thedefaultLoaderargument toClassLoadingmethodscontext- the collection of context information objects to be returned by this stream'smethodinvalid reference
getObjectStreamContext- Throws:
IOException- if the superclass's constructor throws anIOExceptionSecurityException- if the superclass's constructor throws aSecurityExceptionNullPointerException- ifinorcontextisnull
-
-
Method Details
-
resolveClass
protected Class resolveClass(ObjectStreamClass classDesc, boolean readAnnotation, String codebase) throws IOException, ClassNotFoundException Resolves the appropriateClassobject for the stream class descriptorclassDesc.AnnotatedObjectInputStreamimplements this method as follows:Invokes this stream's
readAnnotationmethod to read the annotation string value (possiblynull) for the class descriptor. IfreadAnnotationthrows an exception, then this method throws that exception. Otherwise, a codebase value is chosen as follows: if themethod has been invoked on this stream, then the codebase value chosen is the value that was returned byinvalid reference
useCodebaseAnnotationsreadAnnotation; otherwise, the codebase value chosen isnull.This method then invokes
with the chosen codebase value as the first argument, the name of the class described byinvalid reference
ClassLoading.loadClassclassDescas the second argument, and thedefaultLoader,verifyCodebaseIntegrity, andverifierLoadervalues that were passed to this stream's constructor as the third, fourth, and fifth arguments. IfClassLoading.loadClassthrows aClassNotFoundExceptionand the name of the class described byclassDescequals the Java(TM) programming language keyword for a primitive type orvoid, then this method returns theClasscorresponding to that primitive type orvoid(Integer.TYPEforint,Void.TYPEforvoid, and so forth). Otherwise, ifClassLoading.loadClassthrows an exception, this method throws that exception, and if it returns normally, this method returns theClassreturned byClassLoading.loadClass.- Parameters:
classDesc- the stream class descriptor to resolve- Returns:
- the resolved class
- Throws:
IOException- ifreadAnnotationthrows anIOException, or ifClassLoading.loadClassthrows aMalformedURLExceptionClassNotFoundException- ifreadAnnotationorClassLoading.loadClassthrows aClassNotFoundExceptionNullPointerException- ifclassDescisnull
-
resolveClass
protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException - Overrides:
resolveClassin classObjectInputStream- Throws:
IOExceptionClassNotFoundException
-
readAnnotation
Reads and returns a class annotation string value (possiblynull) that was written by a correspondingAnnotatedObjectOutputStreamimplementation.AnnotatedObjectInputStreamimplements this method to just read the annotation value from this stream usingreadUnshared, and ifreadUnsharedreturns a non-nullvalue that is not aString, anInvalidObjectExceptionis thrown.A subclass can override this method to read the annotation from a different location.
- Returns:
- the class annotation string value read (possibly
null) - Throws:
IOException- if an I/O exception occurs reading the annotationClassNotFoundException- if aClassNotFoundExceptionoccurs reading the annotation
-