John Leuner <[EMAIL PROTECTED]> writes:
> I think I've found a bug in java.lang.Boolean
>
> The existing code for the equals method:
>
> public boolean equals(Object obj) {
> return (obj instanceof Boolean && value == ((Boolean)obj).value);
> }
>
> this doesn't check for a null obj, so I suggest
Try the following code.
public class booleantest
{
public static void main(String argv[])
{
Object obj = null;
if (obj instanceof Boolean)
System.out.println("failed");
else
System.out.println("passed");
}
}
It prints 'passed'. Although you can cast a null object to any type
by itself it is of the null type and an instanceof comparison fails.
Brian
--
Brian Jones <[EMAIL PROTECTED]>