@@ -132,8 +132,15 @@ bool Verifier::relax_access_for(oop loader) {
132132// or pass true for redefinition of any class.
133133static bool is_eligible_for_verification (InstanceKlass* klass, bool should_verify_class) {
134134 Symbol* name = klass->name ();
135+ #if HOTSPOT_TARGET_CLASSLIB == 8
136+ Klass* refl_magic_klass = vmClasses::reflect_MagicAccessorImpl_klass ();
135137
138+ bool is_reflect = refl_magic_klass != nullptr && klass->is_subtype_of (refl_magic_klass);
139+
140+ return (should_verify_class && (!is_reflect) &&
141+ #else
136142 return (should_verify_class &&
143+ #endif
137144 // Can not verify the bytecodes for shared classes because they have
138145 // already been rewritten to contain constant pool cache indices,
139146 // which the verifier can't understand.
@@ -2911,8 +2918,20 @@ void ClassVerifier::verify_invoke_instructions(
29112918 // and we loaded the class. For any other "true" returns (e.g. same class
29122919 // or Object) we either can't get here (same class already excluded above)
29132920 // or we know it is not an interface (i.e. Object).
2921+ #if HOTSPOT_TARGET_CLASSLIB == 8
2922+ bool subtype = false ;
2923+ if (!current_class ()->is_hidden ()) {
2924+ subtype = ref_class_type.is_reference_assignable_from (current_type (), this , false ,
2925+ &is_interface, CHECK_VERIFY (this ));
2926+ } else {
2927+ VerificationType host_klass_type =
2928+ VerificationType::reference_type (current_class ()->nest_host (THREAD)->name ());
2929+ subtype = ref_class_type.is_assignable_from (host_klass_type, this , false , CHECK_VERIFY (this ));
2930+ }
2931+ #else
29142932 bool subtype = ref_class_type.is_reference_assignable_from (current_type (), this , false ,
29152933 &is_interface, CHECK_VERIFY (this ));
2934+ #endif
29162935 if (!subtype) { // Totally unrelated class
29172936 verify_error (ErrorContext::bad_code (bci),
29182937 " Bad invokespecial instruction: "
@@ -2950,7 +2969,28 @@ void ClassVerifier::verify_invoke_instructions(
29502969 } else { // other methods
29512970 // Ensures that target class is assignable to method class.
29522971 if (opcode == Bytecodes::_invokespecial) {
2972+ #if HOTSPOT_TARGET_CLASSLIB == 8
2973+ if (!current_class ()->is_hidden ()) {
2974+ current_frame->pop_stack (current_type (), CHECK_VERIFY (this ));
2975+ } else {
2976+ // anonymous class invokespecial calls: check if the
2977+ // objectref is a subtype of the host_klass of the current class
2978+ // to allow an anonymous class to reference methods in the host_klass
2979+ VerificationType top = current_frame->pop_stack (CHECK_VERIFY (this ));
2980+ VerificationType hosttype =
2981+ VerificationType::reference_type (current_class ()->nest_host (THREAD)->name ());
2982+ bool subtype = hosttype.is_assignable_from (top, this , false , CHECK_VERIFY (this ));
2983+ if (!subtype) {
2984+ verify_error ( ErrorContext::bad_type (current_frame->offset (),
2985+ current_frame->stack_top_ctx (),
2986+ TypeOrigin::implicit (top)),
2987+ " Bad type on operand stack" );
2988+ return ;
2989+ }
2990+ }
2991+ #else
29532992 current_frame->pop_stack (current_type (), CHECK_VERIFY (this ));
2993+ #endif
29542994 } else if (opcode == Bytecodes::_invokevirtual) {
29552995 VerificationType stack_object_type =
29562996 current_frame->pop_stack (ref_class_type, CHECK_VERIFY (this ));
0 commit comments