[9] RFR: 8171139: Simplify ResourceBundle.CacheKey and ClassLoader may not be needed

Mandy Chung mandy.chung at oracle.com
Thu Jan 12 02:35:15 UTC 2017


> On 1/10/17 4:10 PM, Naoto Sato wrote:
>> Hello,
>> 
>> Please review the changes to the subject issue:
>> 
>> https://bugs.openjdk.java.net/browse/JDK-8171139
>> 
>> The changes are located at:
>> 
>> http://cr.openjdk.java.net/~naoto/8171139/webrev.00/
>> 

 622         CacheKey setName(String baseName) {
   Is the setName method used anywhere? I would expect the basename 
   of a CacheKey should be immutable.  Should this be removed?

 698                 Module module = getModule();
 699                 clone.moduleRef =
 700                     module == null

Nit: line 699 can be merged with line 698

 636         Module getModule() {
 637             return moduleRef == null ? null : moduleRef.get();
 638         }
 639 
 640         Module getCallerModule() {
 641             return callerRef == null ? null : callerRef.get();
 642         }

How do we get to moduleRef and callerRef be null?

1487         return getBundleImpl(baseName, locale, caller, caller.getClassLoader(), control);

This assumes caller class is non-null. Perhaps line 1506-1508 should be moved to 1486.

1516         // there's no code in unnamed module of bootstrap class loader so loader
1517         // must be non-null (non-bootstrap) if the caller is from unnamed module
1518         if (loader == null) {
1519             throw new InternalError("null loader");
1520         }
1522         // find resource bundles from unnamed module of given class loader
1523         Module unnamedModule = loader.getUnnamedModule();

Java agent can add to the bootclasspath e.g. via java.lang.instrument.Instrumentation and load classes in unnamed module.  It may call RB::getBundle that will end up here with loader == null.

The above should be:
    Module unnamedModule = loader != null
        			? loader.getUnnamedModule()
        			: BootLoader.getUnnamedModule();

I’ll reply the fix for JDK-8171140 separately.

Mandy



More information about the core-libs-dev mailing list