<i18n dev> RFR: JDK-8280902 ResourceBundle::getBundle may throw NPE when invoked by JNI code with no caller frame [v5]

Tim Prinzing duke at openjdk.java.net
Wed Mar 9 02:05:44 UTC 2022


> 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.

Tim Prinzing has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:

 - Merge branch 'master' into JDK-8280902
 - remove unnecessary variable
 - more suggested changes
 - suggested changes
 - Update src/java.base/share/classes/java/util/ResourceBundle.java
   
   Co-authored-by: Mandy Chung <mandy.chung at oracle.com>
 - Use the unnamed module defined to the system class loader instead of the
   boot class loader.
 - JDK-8280902 ResourceBundle::getBundle may throw NPE when invoked by JNI code with no caller frame

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7663/files
  - new: https://git.openjdk.java.net/jdk/pull/7663/files/45f9b37b..6600e1f5

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7663&range=04
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7663&range=03-04

  Stats: 17900 lines in 516 files changed: 12667 ins; 3251 del; 1982 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7663.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7663/head:pull/7663

PR: https://git.openjdk.java.net/jdk/pull/7663


More information about the i18n-dev mailing list