> > I think I've found a bug in java.lang.Boolean
> > .........
> > 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.
You're right, the VM was implementing the checkcast behaviour for
instanceof. (A copy and paste error!)
I must admit I disassembled java.lang.Boolean from Sun to look at their
equals method, and they do have a check for a null (which is unnecessary).
John Leuner