Hi all,

attached is a small patch that improved the readability of the getObjectField checking code, and the error messages.

2005-07-10  Dalibor Topic  <[EMAIL PROTECTED]>

        * java/io/ObjectOutputStream.java
        (getObjectField): Clarified error checking code, and
        improved exception messages.

cheers,
dalibor topic
Index: java/io/ObjectOutputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectOutputStream.java,v
retrieving revision 1.55
diff -u -r1.55 ObjectOutputStream.java
--- java/io/ObjectOutputStream.java	10 Jul 2005 18:07:15 -0000	1.55
+++ java/io/ObjectOutputStream.java	10 Jul 2005 18:09:51 -0000
@@ -1486,10 +1486,16 @@
 	Field f = getField (klass, field_name);
 	ObjectStreamField of = new ObjectStreamField(f.getName(), f.getType());
 
-	if (of.getTypeString() == null ||
-	    !of.getTypeString().equals(type_code))
+	/* if of is primitive something went wrong
+	 * in the check for primitive classes in writeFields.
+	 */
+	if (of.isPrimitive())
 	  throw new InvalidClassException
-	    ("invalid type code for " + field_name + " in class " + klass.getName());
+	    ("invalid type code for " + field_name + " in class " + klass.getName() + " : object stream field is primitive");
+
+	if (!of.getTypeString().equals(type_code))
+	    throw new InvalidClassException
+		("invalid type code for " + field_name + " in class " + klass.getName() + " : object stream field " + of + " has type string " + of.getTypeString() + " instead of " + type_code);
 
 	Object o = f.get (obj);
 	// FIXME: We should check the type_code here
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to