mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8027458: VM anonymous classes: wrong context for protected access checks
Use the anonymous class's host class for protected access checks Reviewed-by: acorn, coleenp, lfoltan
This commit is contained in:
parent
b6d0b72ec0
commit
9169a8f064
1 changed files with 15 additions and 4 deletions
|
@ -537,15 +537,26 @@ bool Reflection::verify_field_access(Klass* current_class,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Klass* host_class = current_class;
|
||||||
|
while (host_class->oop_is_instance() &&
|
||||||
|
InstanceKlass::cast(host_class)->is_anonymous()) {
|
||||||
|
Klass* next_host_class = InstanceKlass::cast(host_class)->host_klass();
|
||||||
|
if (next_host_class == NULL) break;
|
||||||
|
host_class = next_host_class;
|
||||||
|
}
|
||||||
|
if (host_class == field_class) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (access.is_protected()) {
|
if (access.is_protected()) {
|
||||||
if (!protected_restriction) {
|
if (!protected_restriction) {
|
||||||
// See if current_class is a subclass of field_class
|
// See if current_class (or outermost host class) is a subclass of field_class
|
||||||
if (current_class->is_subclass_of(field_class)) {
|
if (host_class->is_subclass_of(field_class)) {
|
||||||
if (access.is_static() || // static fields are ok, see 6622385
|
if (access.is_static() || // static fields are ok, see 6622385
|
||||||
current_class == resolved_class ||
|
current_class == resolved_class ||
|
||||||
field_class == resolved_class ||
|
field_class == resolved_class ||
|
||||||
current_class->is_subclass_of(resolved_class) ||
|
host_class->is_subclass_of(resolved_class) ||
|
||||||
resolved_class->is_subclass_of(current_class)) {
|
resolved_class->is_subclass_of(host_class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue