-
Bug
-
Resolution: Not an Issue
-
P5
-
None
-
6
-
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
}
}
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
}
}
- relates to
-
JDK-6559179 Unchecked upcast not identified
-
- Closed
-