JDK-7017835 : Compiler improperly implements a casting conversion from Object to int
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-02-08
  • Updated: 2012-03-20
  • Resolved: 2011-02-09
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
All java 7 versions after Changeset: d3ead6731a91 improperly purporting to "fix" the "bug" (which wasn't actually a bug) 6979683


ADDITIONAL OS VERSION INFORMATION :
Windows 7 Enterprise 64-bit

A DESCRIPTION OF THE PROBLEM :
javac was changed in changeset d3ead6731a91 to accept many casting conversions that are not specified in the JLS.  This must be fixed before the product is released, otherise the existence of customer code depending on this misfeature will prevent the bug fix.  In other words, if fixed after the next product release, it would be a breaking change.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile these lines in a method:

Object o = 3;
int i = (int) o;

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should fail to compile.
ACTUAL -
Compiles without error.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
none (unfortunately)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
See steps to reproduce
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use jdk 6

Comments
EVALUATION See 6526446.
09-02-2011

PUBLIC COMMENTS http://mail.openjdk.java.net/pipermail/compiler-dev/2010-September/002339.html
09-02-2011

EVALUATION See related CRs.
09-02-2011