Assignments allow widening before unboxing

XMLWordPrintable

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: P4
    • None
    • Affects Version/s: 6u65, 7u45
    • Component/s: 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
      }

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

              Created:
              Updated:
              Resolved: