[kaffe] Bug Report: Field.set(obj,null)

Laurent Martelli laurent@aopsys.com
Thu Oct 9 18:59:02 2003


Setting a field to null with java.lang.reflect.Field.set() fails with
a NullPointerException. Here's a patch:

--- Field.java.bak	2003-10-10 01:15:05.000000000 +0200
+++ Field.java	2003-10-10 01:15:33.000000000 +0200
@@ -247,7 +247,7 @@
 		}
 	}
 	else {
-		if (!type.isInstance(value)) {
+		if (value!=null && !type.isInstance(value)) {
 			throw new IllegalArgumentException("field type mismatch: Trying to assign a " + value.getClass().getName() + " to " + toString());
 		}
 
Regards,
Laurent

-- 
Laurent Martelli
laurent@aopsys.com                                Java Aspect Components
http://www.aopsys.com/                             http://jac.aopsys.com