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

Assignments allow widening before unboxing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 6u65, 7u45
    • tools
    • None

      The specification for assignment contexts (JLS 5.2) allows an unboxing conversion followed by a widening primitive conversion. It does _not_ allow a widening reference conversion before this occurs. But javac is permitting it.

      The following is allowed:

      <T extends Integer> void test(T arg) {
       int i = arg; // JLS: error; javac: ok
      }

      But not the complementary boxing case:

      void test2(int i) {
       Long l = i; // JLS: error; javac: error
      }

            Unassigned Unassigned
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: