--- old/src/share/classes/com/sun/tools/javac/comp/Attr.java 2013-06-13 15:14:41.783341828 -0400 +++ new/src/share/classes/com/sun/tools/javac/comp/Attr.java 2013-06-13 15:14:41.655340419 -0400 @@ -2991,6 +2991,8 @@ !left.isErroneous() && !right.isErroneous()) { owntype = operator.type.getReturnType(); + // This will figure out when unboxing can happen and + // choose the right comparison operator. int opc = chk.checkOperator(tree.lhs.pos(), (OperatorSymbol)operator, tree.getTag(), @@ -3018,9 +3020,11 @@ } // Check that argument types of a reference ==, != are - // castable to each other, (JLS???). + // castable to each other, (JLS 15.21). Note: unboxing + // comparisons will not have an acmp* opc at this point. if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) { - if (!types.isCastable(left, right, new Warner(tree.pos()))) { + if (!types.isEqualityComparable(left, right, + new Warner(tree.pos()))) { log.error(tree.pos(), "incomparable.types", left, right); } }