On Thu, 3 Mar 2022 16:55:46 GMT, Tim Prinzing <d...@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.
>
> Tim Prinzing has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   more suggested changes

Marked as reviewed by mchung (Reviewer).

src/java.base/share/classes/java/util/ResourceBundle.java line 1570:

> 1568:         Module callerModule = (caller != null) ? caller.getModule()
> 1569:                 : ClassLoader.getSystemClassLoader().getUnnamedModule();
> 1570:         return callerModule;

nit: `callerModule` variable is not needed.  It can simply do:

    return (caller != null) ? caller.getModule()
                            : 
ClassLoader.getSystemClassLoader().getUnnamedModule();

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

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

Reply via email to