-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
5.0
-
generic
-
generic
boolean b = ((Object)null == 3);
should not compile since it's not a numerical equality test
(JLS15.21.1) nor a boolean equality test (15.21.2) nor a
reference equality test (15.21.3). Indeed, it does not compile.
boolean b = (3 == (Object)null);
should not compile for exactly the same reason, but does compile!
I am told javac performs a boxing conversion followed by a
widening reference conversion, which isn't a valid combination
allowed under casting conversion (mentioned in 15.21.3), so I am
not sure what javac is trying to do.
should not compile since it's not a numerical equality test
(JLS15.21.1) nor a boolean equality test (15.21.2) nor a
reference equality test (15.21.3). Indeed, it does not compile.
boolean b = (3 == (Object)null);
should not compile for exactly the same reason, but does compile!
I am told javac performs a boxing conversion followed by a
widening reference conversion, which isn't a valid combination
allowed under casting conversion (mentioned in 15.21.3), so I am
not sure what javac is trying to do.
- duplicates
-
JDK-6526449 javac does not accept semantically valid == test
- Closed