commit-classpath
[Top][All Lists]
Advanced

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

Re: Serialization


From: Guilhem Lavaux
Subject: Re: Serialization
Date: Mon, 29 Dec 2003 11:39:40 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007

Jeroen Frijters wrote:

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.

ok, changed. Thank you for reviewing the code.

Regards,
Guilhem.





reply via email to

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