mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
Put anonymous classes in unnamed package into host class's package. Throw exception if host class's package differs from anonymous class. Reviewed-by: coleenp, acorn
This commit is contained in:
parent
c271d83599
commit
e8e6415b7a
14 changed files with 416 additions and 31 deletions
|
@ -412,13 +412,13 @@ oop Reflection::array_component_type(oop mirror, TRAPS) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static bool under_host_klass(const InstanceKlass* ik, const Klass* host_klass) {
|
||||
static bool under_host_klass(const InstanceKlass* ik, const InstanceKlass* host_klass) {
|
||||
DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000);
|
||||
for (;;) {
|
||||
const Klass* hc = (const Klass*)ik->host_klass();
|
||||
const InstanceKlass* hc = ik->host_klass();
|
||||
if (hc == NULL) return false;
|
||||
if (hc == host_klass) return true;
|
||||
ik = InstanceKlass::cast(hc);
|
||||
ik = hc;
|
||||
|
||||
// There's no way to make a host class loop short of patching memory.
|
||||
// Therefore there cannot be a loop here unless there's another bug.
|
||||
|
@ -436,8 +436,8 @@ static bool can_relax_access_check_for(const Klass* accessor,
|
|||
|
||||
// If either is on the other's host_klass chain, access is OK,
|
||||
// because one is inside the other.
|
||||
if (under_host_klass(accessor_ik, accessee) ||
|
||||
under_host_klass(accessee_ik, accessor))
|
||||
if (under_host_klass(accessor_ik, accessee_ik) ||
|
||||
under_host_klass(accessee_ik, accessor_ik))
|
||||
return true;
|
||||
|
||||
if ((RelaxAccessControlCheck &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue