How do I stop the compiler from complaining at map.get()?
"Type mismatch: cannot convert from ClassInfo<capture#1-of ?> to ClassInfo<T>"
class Context
{
final private Map<Class<?>,ClassInfo<?>> map = new HashMap<>();
<T> ClassInfo<T> getClassInfo(Class<T> c)
{
ClassInfo<T> ci = map.get(c);
if (ci == null) {
ci = new ClassInfo<T>(c);
map.put(c, ci);
}
return(ci);
}
}
Some more information:
ClassInfo contains data about Class, gathered via reflection.
The compiler error does NOT occur with the JDK javac, only when using the Eclipse compiler.
<T> ClassInfo<T> getClassInfo(Class<T> c)