Class ObjectInputStreamWithLoader
public class ObjectInputStreamWithLoader extends ObjectInputStream
{
// Constructors
public ObjectInputStreamWithLoader(InputStream in,
ClassLoader loader) throws IOException,
StreamCorruptedException;
// Methods
protected Class resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException;
}
This class provides methods that allow a class to be resolved by using an existing ClassLoader instance instead of the system class loader. It extends the java.io.ObjectInputStream class, which delegates class resolution to the java.lang.ClassLoader supplied at construction time.
ObjectInputStream
|
+--ObjectInputStreamWithLoader
public ObjectInputStreamWithLoader(InputStream in,
ClassLoader loader) throws IOException, StreamCorruptedException;
Creates an ObjectInputStreamWithLoader object, using the specified input stream and class loader.
Parameter | Description |
in
| The input stream that is used to create the object.
|
loader
| The existing ClassLoader instance.
|
Exceptions:
IllegalArgumentException
if loader is null.
IOException
if an error is encountered while using the underlying stream.
StreamCorruptedException
if the version or magic number is incorrect.
protected Class resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException;
Instructs the class loader that is associated with the ObjectInputStreamWithLoader object to load the class indicated by the specified ObjectStreamClass object.
Return Value:
Returns the loaded class.
Parameter | Description |
classDesc
| The ObjectStreamClass object that indicates the class to load.
|
Exceptions:
ClassNotFoundException
if the class to load cannot be found.
IOException
if the loader encounters an error while reading the class.