commit-classpath
[Top][All Lists]
Advanced

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

FYI: java.io.ObjectInputStream


From: Guilhem Lavaux
Subject: FYI: java.io.ObjectInputStream
Date: Mon, 29 Dec 2003 12:26:44 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007

Hi,

Here is a patch to use a "if (x == null)" structure instead of a "try { } catch".

Guilhem.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.1734
diff -u -r1.1734 ChangeLog
--- ChangeLog   28 Dec 2003 21:50:38 -0000      1.1734
+++ ChangeLog   29 Dec 2003 11:25:04 -0000
@@ -1,3 +1,8 @@
+2003-12-29 Guilhem Lavaux <address@hidden>
+
+       * java/io/ObjectInputStream.java: Use if instead of catching
+       NullPointerException.
+
 2003-12-28  Michael Koch  <address@hidden>
 
        * gnu/java/net/HeaderFieldHelper.java
Index: java/io/ObjectInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.35
diff -u -r1.35 ObjectInputStream.java
--- java/io/ObjectInputStream.java      28 Dec 2003 18:12:43 -0000      1.35
+++ java/io/ObjectInputStream.java      29 Dec 2003 11:25:04 -0000
@@ -1261,35 +1261,24 @@
 
          try
            {
-             try
+             if (field != null)
                {
                  Class field_type = field.getType();
                  
-                 if (type == field_type ||
-                     (type == null && !field_type.isPrimitive()))
-                   {
-                     /* See defaulted */
-                     return field;
-                   }
-        
+                 if ((type == field_type)
+                     || ((type == null) && ! field_type.isPrimitive()))
+                   
+                   /* See defaulted */
+                   return field;
+                 
                  illegal = true;
                  throw new IllegalArgumentException
                    ("Field requested is of type "
                     + field_type.getName()
                     + ", but requested type was "
-                    + (type == null ?  "Object" : type.getName()));
-               }
-             catch (NullPointerException _)
-               {
-                 /* Here we catch NullPointerException, because it may
-                    only come from the call 'field.getType()'. If field
-                    is null, we have to return null and classpath ethic
-                    say we must try to avoid 'if (xxx == null)'.
-                 */
-               }
-             catch (IllegalArgumentException e)
-               {
-                 throw e;
+                    + ((type == null)
+                       ? "Object"
+                       : type.getName()));
                }
              
              return null;

reply via email to

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