ObjectInputStream.java (readObject): Delegate instantation of Externalizable classes to ObjectStreamClass.

2004-09-24  Jeroen Frijters  <jeroen@frijters.net>

	* java/io/ObjectInputStream.java (readObject): Delegate instantation
	of Externalizable classes to ObjectStreamClass.
	* java/io/ObjectStreamClass.java (newInstance): New method to
	instantiate Externalizable (while ignoring the accessibility of
	the constructor). (constructor): New field to cache the constructor.

From-SVN: r88019
This commit is contained in:
Jeroen Frijters 2004-09-24 09:05:10 +00:00 committed by Michael Koch
parent 8ac4bd3706
commit 73eb130916
3 changed files with 58 additions and 23 deletions

View file

@ -291,29 +291,7 @@ public class ObjectInputStream extends InputStream
if (osc.realClassIsExternalizable)
{
Externalizable obj = null;
try
{
obj = (Externalizable)clazz.newInstance();
}
catch (InstantiationException e)
{
throw new ClassNotFoundException
("Instance of " + clazz + " could not be created");
}
catch (IllegalAccessException e)
{
throw new ClassNotFoundException
("Instance of " + clazz + " could not be created because class or "
+ "zero-argument constructor is not accessible");
}
catch (NoSuchMethodError e)
{
throw new ClassNotFoundException
("Instance of " + clazz
+ " could not be created because zero-argument constructor is not defined");
}
Externalizable obj = osc.newInstance();
int handle = assignNewHandle(obj);