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

Warning when casting between interfaces

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      A DESCRIPTION OF THE REQUEST :
      It is possible to cast any interface into any other with nary a warning, even if they are unrelated, unless they are parametrized, in which you get an unchecked cast warning. Some sort of unsafe cast warning should be given in all cases.

      JUSTIFICATION :
      The justification seems obvious: the cast is no less unsafe because the interfaces are raw.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A warning for both casts.
      ACTUAL -
      Unchecked warning only for the second cast.

      ---------- BEGIN SOURCE ----------
      Iterator itr = new ArrayList().iterator();
      Set setr = (Set)itr;
      Iterator<String> it = Arrays.asList("A").iterator();
      List<String> set = (List<String>)it;

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: