hotspot/src/share/vm/prims/jvmtiEnv.cpp
changeset 27478 0eedae0228ac
parent 25325 e3af4e02b0d5
child 27654 4e508c2376f7
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Thu Nov 06 01:31:31 2014 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Nov 05 16:47:37 2014 -0800
@@ -2263,6 +2263,8 @@
   int result_length = instanceK_h->methods()->length();
   jmethodID* result_list = (jmethodID*)jvmtiMalloc(result_length * sizeof(jmethodID));
   int index;
+  bool jmethodids_found = true;
+
   if (JvmtiExport::can_maintain_original_method_order()) {
     // Use the original method ordering indices stored in the class, so we can emit
     // jmethodIDs in the order they appeared in the class file
@@ -2270,14 +2272,40 @@
       Method* m = instanceK_h->methods()->at(index);
       int original_index = instanceK_h->method_ordering()->at(index);
       assert(original_index >= 0 && original_index < result_length, "invalid original method index");
-      jmethodID id = m->jmethod_id();
+      jmethodID id;
+      if (jmethodids_found) {
+        id = m->find_jmethod_id_or_null();
+        if (id == NULL) {
+          // If we find an uninitialized value, make sure there is
+          // enough space for all the uninitialized values we might
+          // find.
+          instanceK_h->ensure_space_for_methodids(index);
+          jmethodids_found = false;
+          id = m->jmethod_id();
+        }
+      } else {
+        id = m->jmethod_id();
+      }
       result_list[original_index] = id;
     }
   } else {
     // otherwise just copy in any order
     for (index = 0; index < result_length; index++) {
       Method* m = instanceK_h->methods()->at(index);
-      jmethodID id = m->jmethod_id();
+      jmethodID id;
+      if (jmethodids_found) {
+        id = m->find_jmethod_id_or_null();
+        if (id == NULL) {
+          // If we find an uninitialized value, make sure there is
+          // enough space for all the uninitialized values we might
+          // find.
+          instanceK_h->ensure_space_for_methodids(index);
+          jmethodids_found = false;
+          id = m->jmethod_id();
+        }
+      } else {
+        id = m->jmethod_id();
+      }
       result_list[index] = id;
     }
   }