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

upcast can never yield an unchecked warning

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Not an Issue
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: