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

upcast can never yield an unchecked warning

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P5
    • None
    • 6
    • specification
    • None
    • generic
    • generic

    Description

      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
            }
      }

      Attachments

        Issue Links

          Activity

            People

              abuckley Alex Buckley
              ahe Peter Ahe
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: