@@ -2244,6 +2244,7 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
22442244// Get field name and signature
22452245 Symbol* field_name = cp->name_ref_at (index);
22462246 Symbol* field_sig = cp->signature_ref_at (index);
2247+ bool is_getfield =false ;
22472248
22482249if (!SignatureVerifier::is_valid_type_signature (field_sig)) {
22492250class_format_error (
@@ -2294,11 +2295,9 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
22942295break ;
22952296 }
22962297case Bytecodes::_getfield: {
2298+ is_getfield =true ;
22972299 stack_object_type = current_frame->pop_stack (
22982300 target_class_type,CHECK_VERIFY (this ));
2299- for (int i =0 ; i < n; i++) {
2300- current_frame->push_stack (field_type[i],CHECK_VERIFY (this ));
2301- }
23022301goto check_protected;
23032302 }
23042303case Bytecodes::_putfield: {
@@ -2328,7 +2327,15 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
23282327 check_protected: {
23292328if (_this_type == stack_object_type)
23302329break ;// stack_object_type must be assignable to _current_class_type
2331- if (was_recursively_verified ())return ;
2330+ if (was_recursively_verified ()) {
2331+ if (is_getfield) {
2332+ // Push field type for getfield.
2333+ for (int i =0 ; i < n; i++) {
2334+ current_frame->push_stack (field_type[i],CHECK_VERIFY (this ));
2335+ }
2336+ }
2337+ return ;
2338+ }
23322339 Symbol* ref_class_name =
23332340 cp->klass_name_at (cp->klass_ref_index_at (index));
23342341if (!name_in_supers (ref_class_name,current_class ()))
@@ -2357,6 +2364,12 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
23572364 }
23582365default :ShouldNotReachHere ();
23592366 }
2367+ if (is_getfield) {
2368+ // Push field type for getfield after doing protection check.
2369+ for (int i =0 ; i < n; i++) {
2370+ current_frame->push_stack (field_type[i],CHECK_VERIFY (this ));
2371+ }
2372+ }
23602373}
23612374
23622375// Look at the method's handlers. If the bci is in the handler's try block