@@ -667,14 +667,39 @@ bool Reflection::verify_member_access(const Klass* current_class,
667667 return true ;
668668 }
669669
670+ #if defined(HOTSPOT_TARGET_CLASSLIB) && HOTSPOT_TARGET_CLASSLIB == 8
671+ const Klass* host_class = current_class;
672+ while (host_class->is_instance_klass ()){
673+ const InstanceKlass* ik = InstanceKlass::cast (host_class);
674+ if (!ik->is_hidden ()) break ;
675+ InstanceKlass* next_host = const_cast <InstanceKlass*>(ik)->nest_host (THREAD);
676+ if (next_host == NULL ) break ;
677+ host_class = next_host;
678+ }
679+ if (host_class == member_class){
680+ return true ;
681+ }
682+ #else
670683 if (current_class == member_class) {
671684 return true ;
672685 }
686+ #endif
673687
674688 if (access.is_protected ()) {
675689 if (!protected_restriction) {
676690 // See if current_class (or outermost host class) is a subclass of member_class
677691 // An interface may not access protected members of j.l.Object
692+ #if defined(HOTSPOT_TARGET_CLASSLIB) && HOTSPOT_TARGET_CLASSLIB == 8
693+ if (!host_class->is_interface () && host_class->is_subclass_of (member_class)) {
694+ if (access.is_static () || // static fields are ok, see 6622385
695+ current_class == resolved_class ||
696+ member_class == resolved_class ||
697+ host_class->is_subclass_of (resolved_class) ||
698+ resolved_class->is_subclass_of (host_class)) {
699+ return true ;
700+ }
701+ }
702+ #else
678703 if (!current_class->is_interface () && current_class->is_subclass_of (member_class)) {
679704 if (access.is_static () || // static fields are ok, see 6622385
680705 current_class == resolved_class ||
@@ -684,6 +709,7 @@ bool Reflection::verify_member_access(const Klass* current_class,
684709 return true ;
685710 }
686711 }
712+ #endif
687713 }
688714 }
689715
0 commit comments