8209361: [AOT] Unexpected number of references for JVMTI_HEAP_REFERENCE_CONSTANT_POOL [111-->111]: 0 (expected at least 1)
authordlong
Thu, 06 Sep 2018 17:45:15 -0700
changeset 51665 cda49f297cb1
parent 51664 a8bdd9c24d37
child 51666 7e6b86eb7914
8209361: [AOT] Unexpected number of references for JVMTI_HEAP_REFERENCE_CONSTANT_POOL [111-->111]: 0 (expected at least 1) Reviewed-by: coleenp, dholmes
src/hotspot/share/prims/jvmtiTagMap.cpp
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Fri Sep 07 09:09:31 2018 +0800
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Thu Sep 06 17:45:15 2018 -0700
@@ -2875,14 +2875,26 @@
       ConstantPool* pool = ik->constants();
       for (int i = 1; i < pool->length(); i++) {
         constantTag tag = pool->tag_at(i).value();
-        if (tag.is_string() || tag.is_klass()) {
+        if (tag.is_string() || tag.is_klass() || tag.is_unresolved_klass()) {
           oop entry;
           if (tag.is_string()) {
             entry = pool->resolved_string_at(i);
             // If the entry is non-null it is resolved.
-            if (entry == NULL) continue;
+            if (entry == NULL) {
+              continue;
+            }
+          } else if (tag.is_klass()) {
+            entry = pool->resolved_klass_at(i)->java_mirror();
           } else {
-            entry = pool->resolved_klass_at(i)->java_mirror();
+            // Code generated by JIT and AOT compilers might not resolve constant
+            // pool entries.  Treat them as resolved if they are loaded.
+            assert(tag.is_unresolved_klass(), "must be");
+            constantPoolHandle cp(Thread::current(), pool);
+            Klass* klass = ConstantPool::klass_at_if_loaded(cp, i);
+            if (klass == NULL) {
+              continue;
+            }
+            entry = klass->java_mirror();
           }
           if (!CallbackInvoker::report_constant_pool_reference(mirror, entry, (jint)i)) {
             return false;