Possible Duplicate:
Type-parameterized field of a generic class becomes invisible after upgrading to Java 7
public class Test{
private String _canYouSeeMe = "yes";
<T extends Test> void genericMethod(T hey){
String s = hey._canYouSeeMe;
}
void method(Test hey){
String s = hey._canYouSeeMe;
}
}
When building against JDK 1.6 this compiles just fine but against 1.7 there is a compiler error in genericMethod(): The field Test._canYouSeeMe is not visible
The error can be resolved by making _canYouSeeMe protected rather than private, but I'm just wondering what has changed from 1.6 to 1.7
T
is a subclass ofTest
then it's also aTest
and we should be able to accessTest._canYouSeeMe
. Actually: castinghey
toTest
makes it work in Java 7. – CatchmentTest
as the argument type and avoid generics. – Catchment