Integrated: JDK-8280902 ResourceBundle::getBundle may throw NPE when invoked by JNI code with no caller frame
Tim Prinzing
duke at openjdk.java.net
Wed Mar 9 04:07:11 UTC 2022
On Wed, 2 Mar 2022 18:56:40 GMT, Tim Prinzing <duke at openjdk.java.net> wrote:
> The caller class returned by Reflection::getCallerClass was used to gain access to it's module in most cases and class loader in one case. I added a method to translate the caller class to caller module so that the decision of what module represents the caller with no stack frame is made in a single place. Calls made to caller.getModule() were replaced with getCallerModule(caller) which returns the system class loader unnamed module if the caller is null.
>
> The one place a class loader was produced from the caller in getBundleImpl it was rewritten to route through the getCallerModule method:
>
> final ClassLoader loader = (caller != null) ?
> caller.getClassLoader() : getLoader(getCallerModule(caller));
>
> A JNI test was added which calls getBundle to fetch a test bundle from a location added to the classpath, fetches a string out of the bundle and verifies it, and calls clearCache.
>
> The javadoc was updated for the caller sensitive methods changed.
This pull request has now been integrated.
Changeset: 31ad80a2
Author: Tim Prinzing <tim.prinzing at oracle.com>
Committer: Mandy Chung <mchung at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/31ad80a229e3f67823ff8f1fc914c5503f184b57
Stats: 218 lines in 4 files changed: 207 ins; 3 del; 8 mod
8280902: ResourceBundle::getBundle may throw NPE when invoked by JNI code with no caller frame
Reviewed-by: naoto, mchung, ihse
-------------
PR: https://git.openjdk.java.net/jdk/pull/7663
More information about the core-libs-dev
mailing list