< prev index next >

src/java.base/share/classes/java/util/ResourceBundle.java

Print this page

        

*** 648,657 **** --- 648,658 ---- // These four are the actual keys for lookup in Map. private String name; private Locale locale; private KeyElementReference<ClassLoader> loaderRef; private KeyElementReference<Module> moduleRef; + private KeyElementReference<Module> callerRef; // bundle format which is necessary for calling // Control.needsReload(). private String format;
*** 678,698 **** private boolean providersChecked; // Boolean.TRUE if the factory method caller provides a ResourceBundleProvier. private Boolean callerHasProvider; ! CacheKey(String baseName, Locale locale, ClassLoader loader, Module module) { Objects.requireNonNull(module); this.name = baseName; this.locale = locale; if (loader == null) { this.loaderRef = null; } else { this.loaderRef = new KeyElementReference<>(loader, referenceQueue, this); } this.moduleRef = new KeyElementReference<>(module, referenceQueue, this); calculateHashCode(); } String getName() { return name; --- 679,701 ---- private boolean providersChecked; // Boolean.TRUE if the factory method caller provides a ResourceBundleProvier. private Boolean callerHasProvider; ! CacheKey(String baseName, Locale locale, ClassLoader loader, Module module, Module caller) { Objects.requireNonNull(module); this.name = baseName; this.locale = locale; if (loader == null) { this.loaderRef = null; } else { this.loaderRef = new KeyElementReference<>(loader, referenceQueue, this); } this.moduleRef = new KeyElementReference<>(module, referenceQueue, this); + this.callerRef = new KeyElementReference<>(caller, referenceQueue, this); + calculateHashCode(); } String getName() { return name;
*** 724,733 **** --- 727,740 ---- Module getModule() { return moduleRef.get(); } + Module getCallerModule() { + return callerRef.get(); + } + ServiceLoader<ResourceBundleProvider> getProviders() { if (!providersChecked) { providers = getServiceLoader(getModule(), name); providersChecked = true; }
*** 765,782 **** if (loaderRef == null) { return otherEntry.loaderRef == null; } ClassLoader loader = getLoader(); Module module = getModule(); return (otherEntry.loaderRef != null) // with a null reference we can no longer find // out which class loader or module was referenced; so // treat it as unequal && (loader != null) && (loader == otherEntry.getLoader()) && (module != null) ! && (module.equals(otherEntry.getModule())); } catch (NullPointerException | ClassCastException e) { } return false; } --- 772,793 ---- if (loaderRef == null) { return otherEntry.loaderRef == null; } ClassLoader loader = getLoader(); Module module = getModule(); + Module caller = getCallerModule(); + return (otherEntry.loaderRef != null) // with a null reference we can no longer find // out which class loader or module was referenced; so // treat it as unequal && (loader != null) && (loader == otherEntry.getLoader()) && (module != null) ! && (module.equals(otherEntry.getModule())) ! && (caller != null) ! && (caller.equals(otherEntry.getCallerModule())); } catch (NullPointerException | ClassCastException e) { } return false; }
*** 794,803 **** --- 805,818 ---- } Module module = getModule(); if (module != null) { hashCodeCache ^= module.hashCode(); } + Module caller = getCallerModule(); + if (caller != null) { + hashCodeCache ^= caller.hashCode(); + } } @Override public Object clone() { try {
*** 806,815 **** --- 821,833 ---- clone.loaderRef = new KeyElementReference<>(getLoader(), referenceQueue, clone); } clone.moduleRef = new KeyElementReference<>(getModule(), referenceQueue, clone); + clone.callerRef = new KeyElementReference<>(getCallerModule(), + referenceQueue, clone); + // Clear the reference to ResourceBundleProviders and the flag clone.providers = null; clone.providersChecked = false; // Clear the reference to a Throwable clone.cause = null;
*** 1663,1673 **** // We create a CacheKey here for use by this call. The base name // loader, and module will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. ! CacheKey cacheKey = new CacheKey(baseName, locale, loader, module); ResourceBundle bundle = null; // Quick lookup of the cache. BundleReference bundleRef = cacheList.get(cacheKey); if (bundleRef != null) { --- 1681,1691 ---- // We create a CacheKey here for use by this call. The base name // loader, and module will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. ! CacheKey cacheKey = new CacheKey(baseName, locale, loader, module, callerModule); ResourceBundle bundle = null; // Quick lookup of the cache. BundleReference bundleRef = cacheList.get(cacheKey); if (bundleRef != null) {
*** 2301,2311 **** clearCache(module.getClassLoader(), module); } private static void clearCache(ClassLoader loader, Module module) { Set<CacheKey> set = cacheList.keySet(); ! set.stream().filter((key) -> (key.getLoader() == loader && key.getModule() == module)) .forEach(set::remove); } /** * Gets an object for the given key from this resource bundle. --- 2319,2330 ---- clearCache(module.getClassLoader(), module); } private static void clearCache(ClassLoader loader, Module module) { Set<CacheKey> set = cacheList.keySet(); ! set.stream() ! .filter((key) -> (key.getLoader() == loader && key.getModule() == module)) .forEach(set::remove); } /** * Gets an object for the given key from this resource bundle.
< prev index next >