commit-classpath
[Top][All Lists]
Advanced

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

RE: Serialization


From: Jeroen Frijters
Subject: RE: Serialization
Date: Mon, 29 Dec 2003 08:57:08 +0100

Guilhem Lavaux wrote:
>+            try
>+              {
>+                Class field_type = field.getType();
>+                
>+                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)'.
>+                */
>+              } 

*Please* don't use exception handling instead of an explicit null check.

Regards,
Jeroen




reply via email to

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