-
Bug
-
Resolution: Fixed
-
P3
-
16
-
None
-
b29
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8269464 | 18 | Mandy Chung | P3 | Resolved | Fixed | b04 |
JDK-8270658 | 17.0.1 | Mandy Chung | P3 | Resolved | Fixed | b03 |
https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#accessClass(java.lang.Class)
Specifically, it throws an exception when accessing an Array Class with a protected inner class as component class when using lookup object with full capabilities
(ie. java.lang.IllegalAccessException: access violation: class [Lp.A$TEST;, from q.B (unnamed module @60215eee) in the testcase provided)
The expected behavior is accessClass should allow the access and return the passed in class.
Testcase:
package p;
public class A {
protected enum TEST { ONE }
}
package q;
import p.A;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public class B extends A {
public static void main(String[] args) throws Throwable {
TEST[] arr = new TEST[1];
Class<?> arrClass = arr.getClass();
//1) is TEST[] visible
try {
MethodHandles.Lookup l = MethodHandles.lookup();
Class<?> accessClass = l.accessClass(arrClass);
System.out.println("Passed! accessClass is: "
+ accessClass.getName());
} catch (Exception e) {
System.out.println(e);
}
//2) Byte code behaviour with TEST[]
meth(null);
//3) MH lookup with TEST[]
MethodHandle mh = MethodHandles.lookup().findStatic(B.class, "meth", MethodType.methodType(void.class, TEST[].class));
mh.invoke(null);
}
public static void meth(TEST[] arr) {
System.out.println("called method");
}
}
- backported by
-
JDK-8269464 Lookup::accessClass fails with IAE when accessing an arrayClass with a protected inner class as component class
- Resolved
-
JDK-8270658 Lookup::accessClass fails with IAE when accessing an arrayClass with a protected inner class as component class
- Resolved
- csr for
-
JDK-8269312 Lookup::accessClass fails with IAE when accessing an arrayClass with a protected inner class as component class
- Closed
- relates to
-
JDK-8150782 findClass / accessClass throw unexpected exceptions
- Resolved
-
JDK-8207027 Lookup.accessClass fails for an array type in the same package when assertions are enabled
- Resolved
-
JDK-8022718 Runtime accessibility checking: protected class, if extended, should be accessible from another package
- Closed
-
JDK-8269689 Update --release 17 symbol information for JDK 17 build 31
- Resolved