src/hotspot/share/prims/jvmtiTagMap.cpp
changeset 51665 cda49f297cb1
parent 51470 84d3126858d5
child 51959 db0c3952de52
--- 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;