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

Print this page




 294      * The cache is a map from cache keys (with bundle base name, locale, and
 295      * class loader) to either a resource bundle or NONEXISTENT_BUNDLE wrapped by a
 296      * BundleReference.
 297      *
 298      * The cache is a ConcurrentMap, allowing the cache to be searched
 299      * concurrently by multiple threads.  This will also allow the cache keys
 300      * to be reclaimed along with the ClassLoaders they reference.
 301      *
 302      * This variable would be better named "cache", but we keep the old
 303      * name for compatibility with some workarounds for bug 4212439.
 304      */
 305     private static final ConcurrentMap<CacheKey, BundleReference> cacheList
 306         = new ConcurrentHashMap<>(INITIAL_CACHE_SIZE);
 307 
 308     /**
 309      * Queue for reference objects referring to class loaders or bundles.
 310      */
 311     private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
 312 
 313     /**



























 314      * The parent bundle of this bundle.
 315      * The parent bundle is searched by {@link #getObject getObject}
 316      * when this bundle does not contain a particular resource.
 317      */
 318     protected ResourceBundle parent = null;
 319 
 320     /**
 321      * The locale for this bundle.
 322      */
 323     private Locale locale = null;
 324 
 325     /**
 326      * The base bundle name for this bundle.
 327      */
 328     private String name;
 329 
 330     /**
 331      * The flag indicating this bundle has expired in the cache.
 332      */
 333     private volatile boolean expired;




 294      * The cache is a map from cache keys (with bundle base name, locale, and
 295      * class loader) to either a resource bundle or NONEXISTENT_BUNDLE wrapped by a
 296      * BundleReference.
 297      *
 298      * The cache is a ConcurrentMap, allowing the cache to be searched
 299      * concurrently by multiple threads.  This will also allow the cache keys
 300      * to be reclaimed along with the ClassLoaders they reference.
 301      *
 302      * This variable would be better named "cache", but we keep the old
 303      * name for compatibility with some workarounds for bug 4212439.
 304      */
 305     private static final ConcurrentMap<CacheKey, BundleReference> cacheList
 306         = new ConcurrentHashMap<>(INITIAL_CACHE_SIZE);
 307 
 308     /**
 309      * Queue for reference objects referring to class loaders or bundles.
 310      */
 311     private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
 312 
 313     /**
 314      * Returns the base name of this bundle, if known.
 315      *
 316      * This is the value of the {@code baseName} parameter that was passed to
 317      * the {@code ResourceBundle.getBundle(...)} method  when the resource
 318      * bundle was loaded.
 319      *
 320      * <p><b>Note:</b>The <code>baseName</code> should be a fully
 321      * qualified class name. However, for compatibility with earlier versions,
 322      * Sun's Java SE Runtime Environments do not verify this, and so it is
 323      * possible to access <code>PropertyResourceBundle</code>s by specifying a
 324      * path name (using "/") instead of a fully qualified class name (using
 325      * "."). It is possible that this method will return such a pathName if
 326      * that is what was given to the {@code ResourceBundle.getBundle(...)}
 327      * method when the resource bundle was loaded.
 328      *
 329      * @return The base name of the resource bundle, a fully qualified
 330      *         class name. May be null if the resource
 331      *         bundle was not loaded through one of the
 332      *         {@code ResourceBundle.getBundle(...)} methods.
 333      *
 334      * @since 1.8
 335      */
 336     public String getBaseBundleName() {
 337         return name;
 338     }
 339 
 340     /**
 341      * The parent bundle of this bundle.
 342      * The parent bundle is searched by {@link #getObject getObject}
 343      * when this bundle does not contain a particular resource.
 344      */
 345     protected ResourceBundle parent = null;
 346 
 347     /**
 348      * The locale for this bundle.
 349      */
 350     private Locale locale = null;
 351 
 352     /**
 353      * The base bundle name for this bundle.
 354      */
 355     private String name;
 356 
 357     /**
 358      * The flag indicating this bundle has expired in the cache.
 359      */
 360     private volatile boolean expired;