-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
7
-
x86
-
linux_ubuntu
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b134)
Java HotSpot(TM) Server VM (build 21.0-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux barkerm-laptop 2.6.32-30-generic-pae #59-Ubuntu SMP Tue Mar 1 23:01:33 UTC 2011 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The following class doesn't compile. The method getError(T accessChange) fails with the error:
PrivateAccessError.java:10: someField has private access in PrivateAccessError
return accesChange.someField;
^
It compiles and runs fine under JDK 6.
public abstract class PrivateAccessError
{
private int someField;
public abstract static class InnerClass<T extends PrivateAccessError>
{
// This method compiles.
public int getOk(PrivateAccessError accesChange)
{
return accesChange.someField;
}
// This method fails to compile.
// "someField has private access in PrivateAccessError"
public int getError(T accesChange)
{
return accesChange.someField;
}
}
}
REGRESSION. Last worked in version 6u24
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the following code:
public abstract class PrivateAccessError
{
private int someField;
public abstract static class InnerClass<T extends PrivateAccessError>
{
// This method compiles.
public int getOk(PrivateAccessError accesChange)
{
return accesChange.someField;
}
// This method fails to compile.
// "someField has private access in PrivateAccessError"
public int getError(T accesChange)
{
return accesChange.someField;
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
PrivateAccessError.java:18: someField has private access in PrivateAccessError
return accesChange.someField;
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public abstract class PrivateAccessError
{
private int someField;
public abstract static class InnerClass<T extends PrivateAccessError>
{
// This method compiles.
public int getOk(PrivateAccessError accesChange)
{
return accesChange.someField;
}
// This method fails to compile.
// "someField has private access in PrivateAccessError"
public int getError(T accesChange)
{
return accesChange.someField;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Make the fields protected not private.
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b134)
Java HotSpot(TM) Server VM (build 21.0-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux barkerm-laptop 2.6.32-30-generic-pae #59-Ubuntu SMP Tue Mar 1 23:01:33 UTC 2011 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The following class doesn't compile. The method getError(T accessChange) fails with the error:
PrivateAccessError.java:10: someField has private access in PrivateAccessError
return accesChange.someField;
^
It compiles and runs fine under JDK 6.
public abstract class PrivateAccessError
{
private int someField;
public abstract static class InnerClass<T extends PrivateAccessError>
{
// This method compiles.
public int getOk(PrivateAccessError accesChange)
{
return accesChange.someField;
}
// This method fails to compile.
// "someField has private access in PrivateAccessError"
public int getError(T accesChange)
{
return accesChange.someField;
}
}
}
REGRESSION. Last worked in version 6u24
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the following code:
public abstract class PrivateAccessError
{
private int someField;
public abstract static class InnerClass<T extends PrivateAccessError>
{
// This method compiles.
public int getOk(PrivateAccessError accesChange)
{
return accesChange.someField;
}
// This method fails to compile.
// "someField has private access in PrivateAccessError"
public int getError(T accesChange)
{
return accesChange.someField;
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful compilation
ACTUAL -
PrivateAccessError.java:18: someField has private access in PrivateAccessError
return accesChange.someField;
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public abstract class PrivateAccessError
{
private int someField;
public abstract static class InnerClass<T extends PrivateAccessError>
{
// This method compiles.
public int getOk(PrivateAccessError accesChange)
{
return accesChange.someField;
}
// This method fails to compile.
// "someField has private access in PrivateAccessError"
public int getError(T accesChange)
{
return accesChange.someField;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Make the fields protected not private.
- duplicates
-
JDK-7022052 Invalid compiler error on private method and generics
-
- Closed
-