8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
authoriklam
Sun, 29 Oct 2017 18:13:18 -0700
changeset 47761 1b0566927c7a
parent 47760 c15f15bcc23e
child 47762 9ccaa4e79030
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false Summary: Do not archive these classes Reviewed-by: jiangli, sspitsyn
src/hotspot/share/classfile/dictionary.cpp
src/hotspot/share/classfile/dictionary.hpp
src/hotspot/share/classfile/systemDictionary.cpp
src/hotspot/share/classfile/systemDictionary.hpp
--- a/src/hotspot/share/classfile/dictionary.cpp	Fri Oct 27 11:44:56 2017 +0200
+++ b/src/hotspot/share/classfile/dictionary.cpp	Sun Oct 29 18:13:18 2017 -0700
@@ -357,6 +357,16 @@
   return entry->is_valid_protection_domain(protection_domain);
 }
 
+#if INCLUDE_CDS
+static bool is_jfr_event_class(Klass *k) {
+  while (k) {
+    if (k->name()->equals("jdk/jfr/Event")) {
+      return true;
+    }
+    k = k->super();
+  }
+  return false;
+}
 
 void Dictionary::reorder_dictionary_for_sharing() {
 
@@ -368,14 +378,22 @@
     while (p != NULL) {
       DictionaryEntry* next = p->next();
       InstanceKlass*ik = p->instance_klass();
-      // we cannot include signed classes in the archive because the certificates
-      // used during dump time may be different than those used during
-      // runtime (due to expiration, etc).
       if (ik->signers() != NULL) {
+        // We cannot include signed classes in the archive because the certificates
+        // used during dump time may be different than those used during
+        // runtime (due to expiration, etc).
         ResourceMark rm;
         tty->print_cr("Preload Warning: Skipping %s from signed JAR",
                        ik->name()->as_C_string());
         free_entry(p);
+      } else if (is_jfr_event_class(ik)) {
+        // We cannot include JFR event classes because they need runtime-specific
+        // instrumentation in order to work with -XX:FlightRecorderOptions=retransform=false.
+        // There are only a small number of these classes, so it's not worthwhile to
+        // support them and make CDS more complicated.
+        ResourceMark rm;
+        tty->print_cr("Skipping JFR event class %s", ik->name()->as_C_string());
+        free_entry(p);
       } else {
         p->set_next(master_list);
         master_list = p;
@@ -400,7 +418,7 @@
     set_entry(index, p);
   }
 }
-
+#endif
 
 SymbolPropertyTable::SymbolPropertyTable(int table_size)
   : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
--- a/src/hotspot/share/classfile/dictionary.hpp	Fri Oct 27 11:44:56 2017 +0200
+++ b/src/hotspot/share/classfile/dictionary.hpp	Sun Oct 29 18:13:18 2017 -0700
@@ -88,7 +88,7 @@
                              Handle protection_domain, TRAPS);
 
   // Sharing support
-  void reorder_dictionary_for_sharing();
+  void reorder_dictionary_for_sharing() NOT_CDS_RETURN;
 
   void print_on(outputStream* st) const;
   void verify();
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Fri Oct 27 11:44:56 2017 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Sun Oct 29 18:13:18 2017 -0700
@@ -2855,9 +2855,11 @@
   return _pd_cache_table->get(protection_domain);
 }
 
+#if INCLUDE_CDS
 void SystemDictionary::reorder_dictionary_for_sharing() {
   ClassLoaderData::the_null_class_loader_data()->dictionary()->reorder_dictionary_for_sharing();
 }
+#endif
 
 size_t SystemDictionary::count_bytes_for_buckets() {
   return ClassLoaderData::the_null_class_loader_data()->dictionary()->count_bytes_for_buckets();
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Fri Oct 27 11:44:56 2017 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Sun Oct 29 18:13:18 2017 -0700
@@ -384,7 +384,7 @@
 
 public:
   // Sharing support.
-  static void reorder_dictionary_for_sharing();
+  static void reorder_dictionary_for_sharing() NOT_CDS_RETURN;
   static void combine_shared_dictionaries();
   static size_t count_bytes_for_buckets();
   static size_t count_bytes_for_table();