Can't figure out this generics problem. I have these interfaces:
public interface LoadableObject
{
}
public interface LoadableObjectFactory<T>
{
}
And now I want to do this:
public class ObjectReference<T extends LoadableObject>
{
Class<? extends LoadableObjectFactory<T>> _cls;
public ObjectReference(LoadableObjectFactory<T> obj)
{
_cls = obj.getClass();
}
}
But I get an error:
incompatible types
found : java.lang.Class<capture#885 of ? extends test.LoadableObjectFactory>
required: java.lang.Class<? extends test.LoadableObjectFactory<T>>
_cls = obj.getClass();
^
I am able to compile if I remove the type params for LoadableObjectFactory
at the definition of _cls
, but then it's an incomplete type... Is there something I'm missing or is it simply impossible?