changeset 9171:986b79fabfa0

8231995: two jtreg tests failed after 8229366 is fixed Reviewed-by: jbachorik
author mbalao
date Tue, 29 Oct 2019 19:53:30 -0300
parents 8e875c964f41
children 78f156419d26
files src/share/vm/classfile/systemDictionary.cpp src/share/vm/jfr/jni/jfrUpcalls.cpp src/share/vm/jfr/jni/jfrUpcalls.hpp
diffstat 3 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/systemDictionary.cpp	Wed Oct 09 16:11:58 2019 +0800
+++ b/src/share/vm/classfile/systemDictionary.cpp	Tue Oct 29 19:53:30 2019 -0300
@@ -39,6 +39,7 @@
 #include "interpreter/bytecodeStream.hpp"
 #include "interpreter/interpreter.hpp"
 #include "jfr/jfrEvents.hpp"
+#include "jfr/jni/jfrUpcalls.hpp"
 #include "memory/filemap.hpp"
 #include "memory/gcLocker.hpp"
 #include "memory/oopFactory.hpp"
@@ -94,6 +95,9 @@
 // lazily initialized klass variables
 Klass* volatile SystemDictionary::_abstract_ownable_synchronizer_klass = NULL;
 
+#if INCLUDE_JFR
+static const Symbol* jfr_event_handler_proxy = NULL;
+#endif // INCLUDE_JFR
 
 // ----------------------------------------------------------------------------
 // Java-level SystemLoader
@@ -1333,6 +1337,25 @@
     if (!k.is_null()) {
       k = find_or_define_instance_class(class_name, class_loader, k, CHECK_(nh));
     }
+#if INCLUDE_JFR
+    else {
+      assert(jfr_event_handler_proxy != NULL, "invariant");
+      if (class_name == jfr_event_handler_proxy) {
+        // EventHandlerProxy class is generated dynamically in
+        // EventHandlerProxyCreator::makeEventHandlerProxyClass
+        // method, so we generate a Java call from here.
+        //
+        // EventHandlerProxy class will finally be defined in
+        // SystemDictionary::resolve_from_stream method, down
+        // the call stack. Bootstrap classloader is parallel-capable,
+        // so no concurrency issues are expected.
+        CLEAR_PENDING_EXCEPTION;
+        k = JfrUpcalls::load_event_handler_proxy_class(THREAD);
+        assert(!k.is_null(), "invariant");
+      }
+    }
+#endif // INCLUDE_JFR
+
     return k;
   } else {
     // Use user specified class loader to load class. Call loadClass operation on class_loader.
@@ -1886,6 +1909,9 @@
   _system_loader_lock_obj = oopFactory::new_intArray(0, CHECK);
   // Initialize basic classes
   initialize_preloaded_classes(CHECK);
+#if INCLUDE_JFR
+  jfr_event_handler_proxy = SymbolTable::new_permanent_symbol("jdk/jfr/proxy/internal/EventHandlerProxy", CHECK);
+#endif // INCLUDE_JFR
 }
 
 // Compact table of directions on the initialization of klasses:
--- a/src/share/vm/jfr/jni/jfrUpcalls.cpp	Wed Oct 09 16:11:58 2019 +0800
+++ b/src/share/vm/jfr/jni/jfrUpcalls.cpp	Tue Oct 29 19:53:30 2019 -0300
@@ -177,3 +177,14 @@
   *new_class_data_len = new_bytes_length;
   *new_class_data = new_bytes;
 }
+
+instanceKlassHandle JfrUpcalls::load_event_handler_proxy_class(TRAPS) {
+  JavaValue result(T_OBJECT);
+  JfrJavaArguments call_args(&result, "jdk/jfr/internal/JVMUpcalls",
+          "getEventHandlerProxyClass", "()Ljava/lang/Class;", CHECK_NULL);
+  JfrJavaSupport::call_static(&call_args, CHECK_NULL);
+  assert(result.get_type() == T_OBJECT, "invariant");
+  instanceHandle h_java_proxy(THREAD, (instanceOop)result.get_jobject());
+  assert(h_java_proxy.not_null(), "invariant");
+  return java_lang_Class::as_Klass(h_java_proxy());
+}
--- a/src/share/vm/jfr/jni/jfrUpcalls.hpp	Wed Oct 09 16:11:58 2019 +0800
+++ b/src/share/vm/jfr/jni/jfrUpcalls.hpp	Tue Oct 29 19:53:30 2019 -0300
@@ -53,6 +53,8 @@
                              jint* new_class_data_len,
                              unsigned char** new_class_data,
                              TRAPS);
+
+  static instanceKlassHandle load_event_handler_proxy_class(TRAPS);
 };
 
 #endif // SHARE_VM_JFR_JNI_JFRUPCALLS_HPP