Guilhem.
Index: java/io/ObjectInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.32
diff -u -r1.32 ObjectInputStream.java
--- java/io/ObjectInputStream.java 1 Aug 2003 03:33:59 -0000 1.32
+++ java/io/ObjectInputStream.java 26 Nov 2003 20:58:42 -0000
@@ -1566,78 +1566,102 @@
private native void callConstructor (Class clazz, Object obj);
private void setBooleanField (Object obj, Class klass, String field_name,
- boolean val)
+ boolean val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setBoolean (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
}
private void setByteField (Object obj, Class klass, String field_name,
- byte val)
+ byte val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setByte (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
}
private void setCharField (Object obj, Class klass, String field_name,
- char val)
+ char val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setChar (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
}
private void setDoubleField (Object obj, Class klass, String field_name,
- double val)
+ double val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setDouble (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
}
private void setFloatField (Object obj, Class klass, String field_name,
- float val)
+ float val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setFloat (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
}
private void setIntField (Object obj, Class klass, String field_name,
- int val)
+ int val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setInt (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
@@ -1645,13 +1669,17 @@
private void setLongField (Object obj, Class klass, String field_name,
- long val)
+ long val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setLong (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
@@ -1659,13 +1687,17 @@
private void setShortField (Object obj, Class klass, String field_name,
- short val)
+ short val) throws IOException
{
try
{
Field f = getField (klass, field_name);
f.setShort (obj, val);
}
+ catch (IllegalArgumentException _)
+ {
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ }
catch (Exception _)
{
}
@@ -1673,17 +1705,24 @@
private void setObjectField (Object obj, Class klass, String field_name,
- String type_code, Object val)
+ String type_code, Object val) throws IOException
{
try
{
- Field f = getField (klass, field_name);
- // FIXME: We should check the type_code here
- f.set (obj, val);
+ Field f = getField (klass, field_name);
+ ObjectStreamField of = new ObjectStreamField(field_name, f.getType());
+
+ if (of.getTypeString() == null ||
+ !of.getTypeString().equals(type_code))
+ throw new InvalidClassException("incompatible field type for " +
klass.getName() + "." + field_name);
+ f.set (obj, val);
}
- catch (Exception _)
+ catch (InvalidClassException e)
{
- }
+ throw e;
+ }
+ catch (Exception _)
+ {}
}
private static final int BUFFER_SIZE = 1024;
_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath

