# HG changeset patch # Parent 1dcea64e9f009b8dd744523f3338f10b0ef9d374 diff --git a/src/share/vm/runtime/reflection.cpp b/src/share/vm/runtime/reflection.cpp --- a/src/share/vm/runtime/reflection.cpp +++ b/src/share/vm/runtime/reflection.cpp @@ -543,15 +543,28 @@ 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 != current_class) tty->print_cr("%s inside %s", current_class->internal_name(), host_class->internal_name()); //@@ + if (!UseNewCode) host_class = current_class; //@@ + if (host_class == field_class) { + return true; + } + if (access.is_protected()) { if (!protected_restriction) { - // See if current_class is a subclass of field_class - if (current_class->is_subclass_of(field_class)) { + // See if current_class (or outermost host class) is a subclass of field_class + if (host_class->is_subclass_of(field_class)) { if (access.is_static() || // static fields are ok, see 6622385 current_class == resolved_class || field_class == resolved_class || - current_class->is_subclass_of(resolved_class) || - resolved_class->is_subclass_of(current_class)) { + host_class->is_subclass_of(resolved_class) || + resolved_class->is_subclass_of(host_class)) { return true; } }