upcast can never yield an unchecked warning

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P5
    • None
    • Affects Version/s: 6
    • Component/s: specification
    • None
    • generic
    • generic

      I am tuning the JDT compiler near unchecked cast, and looking back at the
      official words from JLS, I noticed that it isn't quite covering all
      aspects.
      According to the spec, an upcast can never yield an unchecked warning,
      though javac emits one for this case:

      import java.util.*;
      public class X {

            public static class DatabaseObject {}
            public static class ObjectFormUI<T extends DatabaseObject> {}
            private static final Map<Class<? extends DatabaseObject>, Class<?
      extends ObjectFormUI>> uiMap = new HashMap<Class<? extends DatabaseObject>,
      Class<? extends ObjectFormUI>>();

            public static <T extends DatabaseObject> Class<? extends
      ObjectFormUI<T>> getUI(
                        Class<T> persistentClass) {
                  return null != null
                        ? uiMap.get(persistentClass)
                        : (Class<? extends ObjectFormUI<T>>)
      uiMap.get(persistentClass); // unchecked
            }
      }

            Assignee:
            Alex Buckley
            Reporter:
            Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: