src/share/vm/oops/instanceKlass.cpp

changeset 3670
f7c4174b33ba
parent 3368
52b5d32fbfaf
child 3672
6522ad563f99
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Fri Mar 09 13:34:45 2012 -0800
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Tue Mar 13 13:50:48 2012 -0400
     1.3 @@ -1132,6 +1132,36 @@
     1.4    return probe;
     1.5  }
     1.6  
     1.7 +u2 instanceKlass::enclosing_method_data(int offset) {
     1.8 +  typeArrayOop inner_class_list = inner_classes();
     1.9 +  if (inner_class_list == NULL) {
    1.10 +    return 0;
    1.11 +  }
    1.12 +  int length = inner_class_list->length();
    1.13 +  if (length % inner_class_next_offset == 0) {
    1.14 +    return 0;
    1.15 +  } else {
    1.16 +    int index = length - enclosing_method_attribute_size;
    1.17 +    typeArrayHandle inner_class_list_h(inner_class_list);
    1.18 +    assert(offset < enclosing_method_attribute_size, "invalid offset");
    1.19 +    return inner_class_list_h->ushort_at(index + offset);
    1.20 +  }
    1.21 +}
    1.22 +
    1.23 +void instanceKlass::set_enclosing_method_indices(u2 class_index,
    1.24 +                                                 u2 method_index) {
    1.25 +  typeArrayOop inner_class_list = inner_classes();
    1.26 +  assert (inner_class_list != NULL, "_inner_classes list is not set up");
    1.27 +  int length = inner_class_list->length();
    1.28 +  if (length % inner_class_next_offset == enclosing_method_attribute_size) {
    1.29 +    int index = length - enclosing_method_attribute_size;
    1.30 +    typeArrayHandle inner_class_list_h(inner_class_list);
    1.31 +    inner_class_list_h->ushort_at_put(
    1.32 +      index + enclosing_method_class_index_offset, class_index);
    1.33 +    inner_class_list_h->ushort_at_put(
    1.34 +      index + enclosing_method_method_index_offset, method_index);
    1.35 +  }
    1.36 +}
    1.37  
    1.38  // Lookup or create a jmethodID.
    1.39  // This code is called by the VMThread and JavaThreads so the
    1.40 @@ -2106,28 +2136,21 @@
    1.41    jint access = access_flags().as_int();
    1.42  
    1.43    // But check if it happens to be member class.
    1.44 -  typeArrayOop inner_class_list = inner_classes();
    1.45 -  int length = (inner_class_list == NULL) ? 0 : inner_class_list->length();
    1.46 -  assert (length % instanceKlass::inner_class_next_offset == 0, "just checking");
    1.47 -  if (length > 0) {
    1.48 -    typeArrayHandle inner_class_list_h(THREAD, inner_class_list);
    1.49 -    instanceKlassHandle ik(THREAD, k);
    1.50 -    for (int i = 0; i < length; i += instanceKlass::inner_class_next_offset) {
    1.51 -      int ioff = inner_class_list_h->ushort_at(
    1.52 -                      i + instanceKlass::inner_class_inner_class_info_offset);
    1.53 -
    1.54 -      // Inner class attribute can be zero, skip it.
    1.55 -      // Strange but true:  JVM spec. allows null inner class refs.
    1.56 -      if (ioff == 0) continue;
    1.57 -
    1.58 -      // only look at classes that are already loaded
    1.59 -      // since we are looking for the flags for our self.
    1.60 -      Symbol* inner_name = ik->constants()->klass_name_at(ioff);
    1.61 -      if ((ik->name() == inner_name)) {
    1.62 -        // This is really a member class.
    1.63 -        access = inner_class_list_h->ushort_at(i + instanceKlass::inner_class_access_flags_offset);
    1.64 -        break;
    1.65 -      }
    1.66 +  instanceKlassHandle ik(THREAD, k);
    1.67 +  InnerClassesIterator iter(ik);
    1.68 +  for (; !iter.done(); iter.next()) {
    1.69 +    int ioff = iter.inner_class_info_index();
    1.70 +    // Inner class attribute can be zero, skip it.
    1.71 +    // Strange but true:  JVM spec. allows null inner class refs.
    1.72 +    if (ioff == 0) continue;
    1.73 +
    1.74 +    // only look at classes that are already loaded
    1.75 +    // since we are looking for the flags for our self.
    1.76 +    Symbol* inner_name = ik->constants()->klass_name_at(ioff);
    1.77 +    if ((ik->name() == inner_name)) {
    1.78 +      // This is really a member class.
    1.79 +      access = iter.inner_access_flags();
    1.80 +      break;
    1.81      }
    1.82    }
    1.83    // Remember to strip ACC_SUPER bit

mercurial