760 } 761 762 void LinkResolver::resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) { 763 // Load these early in case the resolve of the containing klass fails 764 Symbol* field = pool->name_ref_at(index); 765 Symbol* sig = pool->signature_ref_at(index); 766 767 // resolve specified klass 768 KlassHandle resolved_klass; 769 resolve_klass(resolved_klass, pool, index, CHECK); 770 771 KlassHandle current_klass(THREAD, pool->pool_holder()); 772 resolve_field(result, resolved_klass, field, sig, current_klass, byte, true, true, CHECK); 773 } 774 775 void LinkResolver::resolve_field(fieldDescriptor& fd, KlassHandle resolved_klass, Symbol* field, Symbol* sig, 776 KlassHandle current_klass, Bytecodes::Code byte, bool check_access, bool initialize_class, 777 TRAPS) { 778 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || 779 byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || 780 (byte == Bytecodes::_nop && !check_access), "bad field access bytecode"); 781 782 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); 783 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic); 784 785 // Check if there's a resolved klass containing the field 786 if (resolved_klass.is_null()) { 787 ResourceMark rm(THREAD); 788 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 789 } 790 791 // Resolve instance field 792 KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); 793 // check if field exists; i.e., if a klass containing the field def has been selected 794 if (sel_klass.is_null()) { 795 ResourceMark rm(THREAD); 796 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 797 } 798 799 if (!check_access) 800 // Access checking may be turned off when calling from within the VM. 801 return; 802 803 // check access 804 check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); | 760 } 761 762 void LinkResolver::resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) { 763 // Load these early in case the resolve of the containing klass fails 764 Symbol* field = pool->name_ref_at(index); 765 Symbol* sig = pool->signature_ref_at(index); 766 767 // resolve specified klass 768 KlassHandle resolved_klass; 769 resolve_klass(resolved_klass, pool, index, CHECK); 770 771 KlassHandle current_klass(THREAD, pool->pool_holder()); 772 resolve_field(result, resolved_klass, field, sig, current_klass, byte, true, true, CHECK); 773 } 774 775 void LinkResolver::resolve_field(fieldDescriptor& fd, KlassHandle resolved_klass, Symbol* field, Symbol* sig, 776 KlassHandle current_klass, Bytecodes::Code byte, bool check_access, bool initialize_class, 777 TRAPS) { 778 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || 779 byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || 780 byte == Bytecodes::_nofast_getfield || byte == Bytecodes::_nofast_putfield || 781 (byte == Bytecodes::_nop && !check_access), "bad field access bytecode"); 782 783 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); 784 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); 785 // Check if there's a resolved klass containing the field 786 if (resolved_klass.is_null()) { 787 ResourceMark rm(THREAD); 788 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 789 } 790 791 // Resolve instance field 792 KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); 793 // check if field exists; i.e., if a klass containing the field def has been selected 794 if (sel_klass.is_null()) { 795 ResourceMark rm(THREAD); 796 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); 797 } 798 799 if (!check_access) 800 // Access checking may be turned off when calling from within the VM. 801 return; 802 803 // check access 804 check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); |