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

5.2: Bad conversions are listed

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      A DESCRIPTION OF THE PROBLEM :
      In the JLS for Java 15, section 5.2 (Assignment Contexts), the following conversions are listed:
         1) a widening reference conversion followed by an unboxing conversion
         2) a widening reference conversion followed by an unboxing conversion, then followed by a widening primitive conversion

      These should probably say "narrowing reference conversion". For example, in:
          int x = (int) (Object) Integer.valueOf(3);
      Object is narrowed to Integer, then unboxed. And in:
          int x = (int) (Object) "test";
      Object is narrowed to Integer, which fails with ClassCastException at runtime.

      The unboxable classes are all final and can't be subclassed, so they can not be widened.
         


      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: