Details
-
Sub-task
-
Resolution: Fixed
-
P4
-
8
-
None
Description
The current behavior of Class::forName(String className) if invoked via JNI code with no Java frame on the stack will use the boot loader to find class. In addition, the caller's loader is also used to check against the package access check (that check will be removed in the future. See JDK-8218203).
JNI FindClass uses the system class loader instead if invoked via JNI invocation interface when there is no associated class loader.
We should re-examine if we should make Class::forName when invoked by JNI code with no caller frame be consistent with JNI FindClass, i.e. use the system class loader if caller is null.
The same behavior should apply to the following caller-sensitive methods related to class loading:
Package::getPackage, Package::getPackages
Runtime::load, Runtime::loadLibrary
System::load, System::loadLibrary
JNI FindClass uses the system class loader instead if invoked via JNI invocation interface when there is no associated class loader.
We should re-examine if we should make Class::forName when invoked by JNI code with no caller frame be consistent with JNI FindClass, i.e. use the system class loader if caller is null.
The same behavior should apply to the following caller-sensitive methods related to class loading:
Package::getPackage, Package::getPackages
Runtime::load, Runtime::loadLibrary
System::load, System::loadLibrary
Attachments
Issue Links
- csr for
-
JDK-8286927 Class::forName(String) defaults to system class loader if the caller is null
- Closed
- relates to
-
JDK-8288485 jni/nullCaller/NullCallerTest.java failing (ppc64)
- Resolved