Troubleshooting "The type parameter T is hiding the type T" warning
Just to expand last answer (I know question is old and closed), I'll provide a Simplest case where you can understand the error:
Imagine an interface with a generic method such as:
<T> Output<T> doSomething(Input<T> input);
If you try to override it as:
@Override
public <Object> Output<Object> soSomething(Input<Object> input){
/*..*/
}
The compiler warns you:
The type parameter Object is hiding the type Object
What it means is that "Object" is a generic label here, it is not java.lang.Object. If you changed Object type to V or whatever arbitrary letter, that would not happen. But you are using and appelative which collides with an actual defined class, so compiler warns you that this Object of you is hiding what otherwise would be understood as the common Object class.
Do you somewhere have a class or interface named T
, or are you using T
as a concrete type name somewhere instead of as a type parameter (which means you might have forgotten somewhere else, for example in an enclosing class, to specify that T
is a type parameter)? I can reproduce your problem with this:
class T { // A concrete type T
}
interface B<T> { // warning: The type parameter T is hiding the type T
}
interface A<T> extends B<T> { // warning: The type parameter T is hiding the type T
T getObject();
}
If I remove class T
, it disappears.