ECJ Java 7 access private of generic [message #1017012] |
Fri, 08 March 2013 15:38 |
Paul Bilnoski Messages: 28 Registered: August 2010 |
Junior Member |
|
|
Migrating some projects from java 6 compliance to java 7, I discovered (something like) this which does not compile under 7 but did under 6:
class X
{
private String m()
{
return null;
}
public <T extends X> void f(T t)
{
t.m(); // "The method m() from the type X is not visible" in Java 7 compliance
}
}
Private methods and fields are not accessible to a local method if the type is a bounded generic type where the bound is the type itself.
Should access to private methods and fields be allowed in this case? Is it a bug in the Java 7 compiler, a bug fix, or adherence to an improvement in the JLS for Java 7?
My code does not depend on this being private (I can change it to package-private or protected), I am just trying to gather more information about the issue.
|
|
|
Powered by
FUDForum. Page generated in 0.02561 seconds