Review request for JDK-8013357: Javac accepts erroneous binary comparison operations

Alex Buckley alex.buckley at
Wed May 29 13:57:20 PDT 2013

Comments on

- @summary is erroneous.

- For each LeftFoo/RightFoo pair, it would be great to identify which 
JLS 15.21.X subsection applies.

- LeftNumber/RightNumber are asserted to compile OK. This is perplexing. 
Their operands are Number and int, and Number is not convertible to 
numeric type (per our private mail) so the == comparison is illegal. 
Having accepted the comparison, javac implements it by doing a reference 
comparison (if_acmpne) of the Number with an Integer obtained by boxing 
the literal - suffice to say, this has poor results. Legal numeric 
equality comparisons are implemented with unboxing + numeric comparison 
bytecodes (if_icmpne, dcmpl, etc) which has a pleasing symmetry with JLS 


On 5/29/2013 12:53 PM, Eric McCorkle wrote:
> Hello,
> Please review my latest patch for this problem.  Since my earlier review
> request, several things have happened:
> 1) A CCC has been submitted, reviewed (at length) and approved.
> 2) I've confirmed the correct behavior wrt object-primitive comparisons.
> 3) I've fixed some errors in our tests, which would not compile when
> javac enforces the correct type rules.
> 4) This change has been flagged for a release note.
> The webrev is here:

More information about the compiler-dev mailing list