JDK-6526449 : javac does not accept semantically valid == test
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0,6
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2007-02-19
  • Updated: 2010-10-26
  • Resolved: 2010-10-26
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
boolean b = (3 == (Object)null);
  compiles because javac performs a boxing conversion followed by a
  widening reference conversion. This isn't currently a valid combination
  under casting conversion (as required by 15.21.3) but 6526446 will
  expand casting conversion and it will become valid.

However, this does not compile, and should:

boolean b = ((Object)null == 3);  // incomparable types: java.lang.Object and int

Comments
EVALUATION Fixed by 6979683.
26-10-2010