In the following code, Eclipse shows warning in methodB: The type parameter T is hiding the type T.
private void methodA(final Map<String, T> map) {}
private <T> void methodB(final Map<String, T> map) {}
The root cause is that when write methodA, I made a mistake: I forgot to declare type variable.
As I configured Eclipse Save Action: it will automatically organize imports not declared classes; in Map<String, T> map, the T is actually: org.apache.poi.ss.formula.functions.T, so methodA actually compiles.
In methodB, the T is actually type variable, so eclipse shows the warning: The type parameter T is hiding the type T.
This is configured in Preferences > Java > Compiler > Errors/Warnings > Type parameter hies another type > Choose Warning
Lesson Learned
During code review, don't ignore imports part.
Make sure what imports is actually we want.
Don't use T as type variables, use E, K, V etc.
Understand the generic syntax.
private void methodA(final Map<String, T> map) {}
private <T> void methodB(final Map<String, T> map) {}
The root cause is that when write methodA, I made a mistake: I forgot to declare type variable.
As I configured Eclipse Save Action: it will automatically organize imports not declared classes; in Map<String, T> map, the T is actually: org.apache.poi.ss.formula.functions.T, so methodA actually compiles.
In methodB, the T is actually type variable, so eclipse shows the warning: The type parameter T is hiding the type T.
This is configured in Preferences > Java > Compiler > Errors/Warnings > Type parameter hies another type > Choose Warning
Lesson Learned
During code review, don't ignore imports part.
Make sure what imports is actually we want.
Don't use T as type variables, use E, K, V etc.
Understand the generic syntax.