< prev index next >

src/share/vm/oops/instanceKlass.cpp

Print this page




1152       // to _oop_map_cache. C++ compilers on ppc do not emit the
1153       // required memory barrier only because of the volatile
1154       // qualifier of _oop_map_cache.
1155       OrderAccess::release_store_ptr(&_oop_map_cache, new OopMapCache());
1156     }
1157   }
1158   // _oop_map_cache is constant after init; lookup below does is own locking.
1159   _oop_map_cache->lookup(method, bci, entry_for);
1160 }
1161 
1162 
1163 bool InstanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
1164   for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
1165     Symbol* f_name = fs.name();
1166     Symbol* f_sig  = fs.signature();
1167     if (f_name == name && f_sig == sig) {
1168       fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index());
1169       return true;
1170     }
1171   }



















































1172   return false;
1173 }
1174 
1175 
1176 Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
1177   const int n = local_interfaces()->length();
1178   for (int i = 0; i < n; i++) {
1179     Klass* intf1 = local_interfaces()->at(i);
1180     assert(intf1->is_interface(), "just checking type");
1181     // search for field in current interface
1182     if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) {
1183       assert(fd->is_static(), "interface field must be static");
1184       return intf1;
1185     }
1186     // search for field in direct superinterfaces
1187     Klass* intf2 = InstanceKlass::cast(intf1)->find_interface_field(name, sig, fd);
1188     if (intf2 != NULL) return intf2;
1189   }
1190   // otherwise field lookup fails
1191   return NULL;




1152       // to _oop_map_cache. C++ compilers on ppc do not emit the
1153       // required memory barrier only because of the volatile
1154       // qualifier of _oop_map_cache.
1155       OrderAccess::release_store_ptr(&_oop_map_cache, new OopMapCache());
1156     }
1157   }
1158   // _oop_map_cache is constant after init; lookup below does is own locking.
1159   _oop_map_cache->lookup(method, bci, entry_for);
1160 }
1161 
1162 
1163 bool InstanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
1164   for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
1165     Symbol* f_name = fs.name();
1166     Symbol* f_sig  = fs.signature();
1167     if (f_name == name && f_sig == sig) {
1168       fd->reinitialize(const_cast<InstanceKlass*>(this), fs.index());
1169       return true;
1170     }
1171   }
1172   // field not found. Try to search for an accessor-method-pair
1173   bool found = false;
1174   int length = sig->utf8_length();
1175   if (length > 0) {
1176     // extract original signature+ one \0 char
1177     char fSig[length+1];
1178     sig->as_C_string(fSig,length+1);
1179 
1180     // the signature of the get-Method is two chars longer + \0
1181     char get_sig[length+3];
1182     sprintf(get_sig,"()%s",fSig);
1183 
1184     // the signature of the put-Method is three chars longer + \0
1185     char put_sig[length+4];
1186     sprintf(put_sig,"(%s)V",fSig);
1187     
1188     // Look through all methods in the class.
1189     Array<Method*>* methods = this->methods();
1190     for (int i = 0; i < methods->length(); i++) {
1191       Method* m = methods->at(i);
1192       
1193       // extract name of accessor-field 
1194       u2 af = m->accessor_field_name();
1195       // Is zero an valid index?
1196       if (af != 0) {
1197         Symbol* fn = m->constMethod()->constants()->symbol_at(af);
1198         char mname[name->utf8_length()+1];
1199         name->as_C_string(mname,name->utf8_length()+1);
1200         // if fieldname matches. record match and store name and
1201         // signature in fielddescriptor
1202         if (fn->equals(mname)) {
1203           found = true;
1204           fd->set_field_name_from_accessor(af);
1205           fd->set_sig_for_accessor(sig);
1206           if (m->signature()->equals(get_sig)) {
1207             // remember get method
1208             fd->set_get_accessor(m->method_idnum());
1209           }else if (m->signature()->equals(put_sig)) {
1210             // remember put method
1211             fd->set_put_accessor(m->method_idnum());
1212           }
1213         }
1214       }
1215     }
1216   }
1217   if (found) {
1218     // initialize accesor-values in fielddescriptor
1219     fd->reinitialize_accessor(const_cast<InstanceKlass*>(this));
1220     // is the fielddescriptor a valid accessor-fielddescriptor?
1221     return fd->is_accessor();
1222   }
1223   return false;
1224 }
1225 
1226 
1227 Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
1228   const int n = local_interfaces()->length();
1229   for (int i = 0; i < n; i++) {
1230     Klass* intf1 = local_interfaces()->at(i);
1231     assert(intf1->is_interface(), "just checking type");
1232     // search for field in current interface
1233     if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) {
1234       assert(fd->is_static(), "interface field must be static");
1235       return intf1;
1236     }
1237     // search for field in direct superinterfaces
1238     Klass* intf2 = InstanceKlass::cast(intf1)->find_interface_field(name, sig, fd);
1239     if (intf2 != NULL) return intf2;
1240   }
1241   // otherwise field lookup fails
1242   return NULL;


< prev index next >