JDK-8046017 : javac 1.8.0_05 unable to compile valid code (regression)
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u5
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-06-03
  • Updated: 2014-06-05
  • Resolved: 2014-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8u20Resolved
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux shadow 3.13.6-gentoo-20 #11 SMP Thu Apr 3 15:34:27 NOVT 2014 x86_64 Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz GenuineIntel GNU/Linux

A DESCRIPTION OF THE PROBLEM :
javac 1.8 fails to compile code previously valid for 1.7

REGRESSION.  Last worked in version 7u60

ADDITIONAL REGRESSION INFORMATION: 
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile code from example with javac 1.7 and javac 1.8

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No errors

ACTUAL -
Buggy.java:5: error: incomparable types: boolean and Object
        boolean flag = true == new Object();
                            ^
1 error

using javac 1.8

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
class Buggy {
    boolean flag = true == new Object();
}

---------- END SOURCE ----------


Comments
According to JLS 8 (15.21): The equality operators may be used to compare two operands that are convertible (��5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the null type. All other cases result in a compile-time error. So if you compare a boolean and a reference type the compiler should emit a compile-time error as in this case. This modification has been included in JDK-8013357. The public documentation reflects this change: http://docs.oracle.com/javase/8/docs/technotes/tools/enhancements-8.html
05-06-2014

I can confirm the regression. In 7 true was converted to a Boolean and the result was then compared to new Object.
05-06-2014