<i18n dev> RFR: 8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey [v3]

Pavel Rappo prappo at openjdk.org
Fri Jun 23 15:15:11 UTC 2023


On Fri, 23 Jun 2023 13:46:04 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/ResourceBundle.java line 743:
>> 
>>> 741:                 return ((module != null) && (module.equals(otherEntry.getModule())) &&
>>> 742:                         (caller != null) && (caller.equals(otherEntry.getCallerModule())));
>>> 743:             } catch (NullPointerException | ClassCastException e) {
>> 
>> Are we sure that NPE can only be thrown when calling equals on `name` or `locale` and not, for example, from `getModule()` or `getCallerModule()`?
>
> Yes:
> 
> CacheKey(String baseName, Locale locale, Module module, Module caller) {
>     Objects.requireNonNull(module);
>     Objects.requireNonNull(caller);
> 
>     this.name = baseName;
>     this.locale = locale;
>     this.moduleRef = new KeyElementReference<>(module, referenceQueue, this);
>     this.callerRef = new KeyElementReference<>(caller, referenceQueue, this);
>     this.modulesHash = module.hashCode() ^ caller.hashCode();
> }

I'll run our CI, and if all good, I'll approve this PR. If nothing else, this change seems reasonable and correct.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/12328#discussion_r1239940961


More information about the i18n-dev mailing list