-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b05
-
x86
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2152448 | OpenJDK6 | Jonathan Gibbons | P3 | Closed | Not an Issue |
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b91, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When a class A has a generic field with a private class P as parameter, and another class Main without access to P uses this field, generics may insert a casts to P in Main, to which it has no access. This results in an IllegalAccessError.
This may actually be a bug in the specification, I'm not sure.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the provided code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The compiler shouldn't accept such code.
ACTUAL -
java.lang.IllegalAccessError: tried to access class a.A$P from class Main
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Main.java:
public class Main {
public static void main(String[] args) {
a.A myA = new a.A();
myA.p = myA.vec.get(0);
}
}
a/A.java:
package a;
import java.util.Vector;
public class A {
private class P {}
public P p;
public Vector<P> vec;
public A() {
vec = new Vector<P>();
vec.add(new P());
}
}
---------- END SOURCE ----------
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b91, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
When a class A has a generic field with a private class P as parameter, and another class Main without access to P uses this field, generics may insert a casts to P in Main, to which it has no access. This results in an IllegalAccessError.
This may actually be a bug in the specification, I'm not sure.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the provided code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The compiler shouldn't accept such code.
ACTUAL -
java.lang.IllegalAccessError: tried to access class a.A$P from class Main
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Main.java:
public class Main {
public static void main(String[] args) {
a.A myA = new a.A();
myA.p = myA.vec.get(0);
}
}
a/A.java:
package a;
import java.util.Vector;
public class A {
private class P {}
public P p;
public Vector<P> vec;
public A() {
vec = new Vector<P>();
vec.add(new P());
}
}
---------- END SOURCE ----------
- backported by
-
JDK-2152448 Cast inserted by generics can cause IllegalAccessError
-
- Closed
-
- relates to
-
JDK-7151070 NullPointerException in Resolve.isAccessible
-
- Closed
-