Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7017835

Compiler improperly implements a casting conversion from Object to int

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 7
    • tools
    • x86
    • windows_7

      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

            mcimadamore Maurizio Cimadamore
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: