8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false

Do not archive these classes

Reviewed-by: jiangli, sspitsyn
This commit is contained in:
Ioi Lam 2017-10-29 18:13:18 -07:00
parent 97d1978c0f
commit a422994296
4 changed files with 26 additions and 6 deletions

View file

@ -357,6 +357,16 @@ bool Dictionary::is_valid_protection_domain(int index, unsigned int hash,
return entry->is_valid_protection_domain(protection_domain); 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() { void Dictionary::reorder_dictionary_for_sharing() {
@ -368,14 +378,22 @@ void Dictionary::reorder_dictionary_for_sharing() {
while (p != NULL) { while (p != NULL) {
DictionaryEntry* next = p->next(); DictionaryEntry* next = p->next();
InstanceKlass*ik = p->instance_klass(); 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) { 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; ResourceMark rm;
tty->print_cr("Preload Warning: Skipping %s from signed JAR", tty->print_cr("Preload Warning: Skipping %s from signed JAR",
ik->name()->as_C_string()); ik->name()->as_C_string());
free_entry(p); 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 { } else {
p->set_next(master_list); p->set_next(master_list);
master_list = p; master_list = p;
@ -400,7 +418,7 @@ void Dictionary::reorder_dictionary_for_sharing() {
set_entry(index, p); set_entry(index, p);
} }
} }
#endif
SymbolPropertyTable::SymbolPropertyTable(int table_size) SymbolPropertyTable::SymbolPropertyTable(int table_size)
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry)) : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))

View file

@ -88,7 +88,7 @@ public:
Handle protection_domain, TRAPS); Handle protection_domain, TRAPS);
// Sharing support // Sharing support
void reorder_dictionary_for_sharing(); void reorder_dictionary_for_sharing() NOT_CDS_RETURN;
void print_on(outputStream* st) const; void print_on(outputStream* st) const;
void verify(); void verify();

View file

@ -2855,9 +2855,11 @@ ProtectionDomainCacheEntry* SystemDictionary::cache_get(Handle protection_domain
return _pd_cache_table->get(protection_domain); return _pd_cache_table->get(protection_domain);
} }
#if INCLUDE_CDS
void SystemDictionary::reorder_dictionary_for_sharing() { void SystemDictionary::reorder_dictionary_for_sharing() {
ClassLoaderData::the_null_class_loader_data()->dictionary()->reorder_dictionary_for_sharing(); ClassLoaderData::the_null_class_loader_data()->dictionary()->reorder_dictionary_for_sharing();
} }
#endif
size_t SystemDictionary::count_bytes_for_buckets() { size_t SystemDictionary::count_bytes_for_buckets() {
return ClassLoaderData::the_null_class_loader_data()->dictionary()->count_bytes_for_buckets(); return ClassLoaderData::the_null_class_loader_data()->dictionary()->count_bytes_for_buckets();

View file

@ -384,7 +384,7 @@ public:
public: public:
// Sharing support. // Sharing support.
static void reorder_dictionary_for_sharing(); static void reorder_dictionary_for_sharing() NOT_CDS_RETURN;
static void combine_shared_dictionaries(); static void combine_shared_dictionaries();
static size_t count_bytes_for_buckets(); static size_t count_bytes_for_buckets();
static size_t count_bytes_for_table(); static size_t count_bytes_for_table();