classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: improved getObjectField checks and error message


From: Dalibor Topic
Subject: [cp-patches] FYI: improved getObjectField checks and error message
Date: Sun, 10 Jul 2005 20:15:48 +0200
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

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  <address@hidden>

        * 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]