--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Tue Jul 19 09:30:30 2016 +0200
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Tue Jul 19 13:52:14 2016 -0400
@@ -1246,12 +1246,16 @@
instanceKlassHandle SystemDictionary::load_shared_class(
Symbol* class_name, Handle class_loader, TRAPS) {
- instanceKlassHandle ik (THREAD, find_shared_class(class_name));
- // Make sure we only return the boot class for the NULL classloader.
- if (ik.not_null() &&
- ik->is_shared_boot_class() && class_loader.is_null()) {
- Handle protection_domain;
- return load_shared_class(ik, class_loader, protection_domain, THREAD);
+ // Don't load shared class when JvmtiExport::should_post_class_file_load_hook()
+ // is enabled since posting CFLH is not supported when loading shared class.
+ if (!JvmtiExport::should_post_class_file_load_hook()) {
+ instanceKlassHandle ik (THREAD, find_shared_class(class_name));
+ // Make sure we only return the boot class for the NULL classloader.
+ if (ik.not_null() &&
+ ik->is_shared_boot_class() && class_loader.is_null()) {
+ Handle protection_domain;
+ return load_shared_class(ik, class_loader, protection_domain, THREAD);
+ }
}
return instanceKlassHandle();
}
@@ -1334,8 +1338,14 @@
instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
Handle class_loader,
Handle protection_domain, TRAPS) {
+ instanceKlassHandle nh = instanceKlassHandle(); // null Handle
+ if (JvmtiExport::should_post_class_file_load_hook()) {
+ // Don't load shared class when JvmtiExport::should_post_class_file_load_hook()
+ // is enabled since posting CFLH is not supported when loading shared class.
+ return nh;
+ }
+
if (ik.not_null()) {
- instanceKlassHandle nh = instanceKlassHandle(); // null Handle
Symbol* class_name = ik->name();
bool visible = is_shared_class_visible(