src/share/vm/runtime/fieldDescriptor.cpp

changeset 6472
2b8e28fdf503
parent 5732
b2e698d2276c
child 6876
710a3c8b516e
child 9507
7e72702243a4
     1.1 --- a/src/share/vm/runtime/fieldDescriptor.cpp	Wed Oct 16 10:52:41 2013 +0200
     1.2 +++ b/src/share/vm/runtime/fieldDescriptor.cpp	Tue Nov 05 17:38:04 2013 -0800
     1.3 @@ -97,18 +97,32 @@
     1.4    return constants()->uncached_string_at(initial_value_index(), CHECK_0);
     1.5  }
     1.6  
     1.7 -void fieldDescriptor::initialize(InstanceKlass* ik, int index) {
     1.8 -  _cp = ik->constants();
     1.9 +void fieldDescriptor::reinitialize(InstanceKlass* ik, int index) {
    1.10 +  if (_cp.is_null() || field_holder() != ik) {
    1.11 +    _cp = constantPoolHandle(Thread::current(), ik->constants());
    1.12 +    // _cp should now reference ik's constant pool; i.e., ik is now field_holder.
    1.13 +    assert(field_holder() == ik, "must be already initialized to this class");
    1.14 +  }
    1.15    FieldInfo* f = ik->field(index);
    1.16    assert(!f->is_internal(), "regular Java fields only");
    1.17  
    1.18    _access_flags = accessFlags_from(f->access_flags());
    1.19    guarantee(f->name_index() != 0 && f->signature_index() != 0, "bad constant pool index for fieldDescriptor");
    1.20    _index = index;
    1.21 +  verify();
    1.22  }
    1.23  
    1.24  #ifndef PRODUCT
    1.25  
    1.26 +void fieldDescriptor::verify() const {
    1.27 +  if (_cp.is_null()) {
    1.28 +    assert(_index == badInt, "constructor must be called");  // see constructor
    1.29 +  } else {
    1.30 +    assert(_index >= 0, "good index");
    1.31 +    assert(_index < field_holder()->java_fields_count(), "oob");
    1.32 +  }
    1.33 +}
    1.34 +
    1.35  void fieldDescriptor::print_on(outputStream* st) const {
    1.36    access_flags().print_on(st);
    1.37    name()->print_value_on(st);

mercurial