Consider the following case:
public class p1.IAE {...}
/*package*/ class p1.Test {...}
public class p2.AnonClass {...} // VM anonymous class w/ p1.Test provided as a host class.
If AnonClass tries to access p1.Test the following exception is thrown:
java.lang.IllegalAccessError: tried to access class p1.T from class p2.AnonClass/1309552426
at p2.AnonClass/1309552426.test(Unknown Source)
... 5 more
Though AnonClass tries to access package-private in p1 from p2, for VM anonymous class inherit it's host class should be used for all access checks. p1.IAE has access to p1.Test.
Test case is attached.
How to run:
$ javac -XDignore.symbol.file -d . IAE.java
$ java -Xbootclasspath/a:. p1.IAE
public class p1.IAE {...}
/*package*/ class p1.Test {...}
public class p2.AnonClass {...} // VM anonymous class w/ p1.Test provided as a host class.
If AnonClass tries to access p1.Test the following exception is thrown:
java.lang.IllegalAccessError: tried to access class p1.T from class p2.AnonClass/1309552426
at p2.AnonClass/1309552426.test(Unknown Source)
... 5 more
Though AnonClass tries to access package-private in p1 from p2, for VM anonymous class inherit it's host class should be used for all access checks. p1.IAE has access to p1.Test.
Test case is attached.
How to run:
$ javac -XDignore.symbol.file -d . IAE.java
$ java -Xbootclasspath/a:. p1.IAE
- relates to
-
JDK-8149574 Fix java/lang/invoke/MethodHandleImpl's use of Unsafe.defineAnonymousClass()
-
- Resolved
-
-
JDK-8149835 StringConcatFactory should emit classes with the same package as the host class
-
- Resolved
-
-
JDK-8140665 SIGSEGV when a primitive type's class is used as the host class in a call to DefineAnonymousClass call
-
- Resolved
-