I'm trying to extend a generic class, like:
public class GenericClass<T> implements GenericClassInterface<T>
{
public T myMethod(String typeID) {
T test = _get_test_value_; // here I use jackson to retrieve T de-serialized from JSON
return T;
}
}
Then I extend that class:
public class SpecificClass extends GenericClass<CustomType> implements SpecificClassInterface
{
public CustomType getIstance(String typeID) {
return super.myMethod(typeID);
}
}
The code compiles correctly, but when I debug I find out that type T, when myMethod is called from SpecificClass, is Object, and not CustomType, even if I specified CustomType when I extended GenericClass in SpecificClass.
How come? Is this a limitation of generics in Java?