Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8239593: Bogus warning "Re-registering of platform native method" for…
… a JVMTI agent

Reviewed-by: dcubed, alanb, hseigel
  • Loading branch information
David Holmes committed Mar 17, 2020
1 parent c003fff commit f959b012034d61c3da6350b51b45aea722b064e3
Showing with 19 additions and 10 deletions.
  1. +19 −10 src/hotspot/share/prims/jni.cpp
@@ -2811,17 +2811,26 @@ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz,

Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));

// There are no restrictions on native code registering native methods, which
// allows agents to redefine the bindings to native methods. But we issue a
// warning if any code running outside of the boot/platform loader is rebinding
// any native methods in classes loaded by the boot/platform loader.
Klass* caller = thread->security_get_caller_class(1);
// There are no restrictions on native code registering native methods,
// which allows agents to redefine the bindings to native methods, however
// we issue a warning if any code running outside of the boot/platform
// loader is rebinding any native methods in classes loaded by the
// boot/platform loader that are in named modules. That will catch changes
// to platform classes while excluding classes added to the bootclasspath.
bool do_warning = false;
oop cl = k->class_loader();
if (cl == NULL || SystemDictionary::is_platform_class_loader(cl)) {
// If no caller class, or caller class has a different loader, then
// issue a warning below.
do_warning = (caller == NULL) || caller->class_loader() != cl;

// Only instanceKlasses can have native methods
if (k->is_instance_klass()) {
oop cl = k->class_loader();
InstanceKlass* ik = InstanceKlass::cast(k);
// Check for a platform class
if ((cl == NULL || SystemDictionary::is_platform_class_loader(cl)) &&
ik->module()->is_named()) {
Klass* caller = thread->security_get_caller_class(1);
// If no caller class, or caller class has a different loader, then
// issue a warning below.
do_warning = (caller == NULL) || caller->class_loader() != cl;
}
}


0 comments on commit f959b01

Please sign in to comment.