RFR: 8013839: Enhance Logger API for handling of resource bundles

Naoto Sato naoto.sato at oracle.com
Fri Sep 20 17:11:04 UTC 2013

Hi Daniel,

I only looked at the ResourceBundle portion of the changeset, and it 
looks good to me (assuming it'll go through the CCC).


On 9/20/13 5:33 AM, Daniel Fuchs wrote:
> Hi,
> Please find below a patch for:
> 8013839: Enhance Logger API for handling of resource bundles, and
> 4814565: (rb) add method to get basename from a ResourceBundle
> <http://cr.openjdk.java.net/~dfuchs/webrev_8013839/webrev.06/>
>     1. It adds a ResourceBundle.getBaseBundleName() method,
>     2. It adds a Logger.setResourceBundle(ResourceBundle) method,
>     3. It adds a series of Logger.logrb(...) that take a ResourceBundle
>          object instead of a ResourceBundle name.
>          The previous versions of Logger.logrb(...) that took a
>          resource bundle name are therefore no longer needed,
>          they offer no added value above the new methods, and
>          are thus now deprecated.
> Logger.getLogger(name, rbname) will continue to work as before,
>       and will also throw an exception if a RB with a different name
>       has been set before, either through setResourceBundle or
>       Logger.getLogger(name, rbname).
> Logger.setResourceBundle works similarly to
>       Logger.getLogger(name, rbname) in the sense that it will not
>       allow to replace an existing bundle, unless both have the same
>       name. Like for Logger.getLogger(name, rbname) - it doesn't matter
>       by which method the previous bundle has been set.
>       This is mostly for consistency of the API - if thread A has
>       requested a logger with resource bundle name 'foo.Bundle'
>       and thread B attempts to set the resource bundle of that
>       logger to 'bar.Bundle' then thread B will get an IAE.
>       The resource bundle passed to Logger.setResourceBundle *must*
>       have a base name. Note that ResourceBundle objects will have
>       a base name by default if they have been loaded through
>       one of the ResourceBundle.getBundle(...) methods;
>       If ResourceBundle.getBaseBundleName() returns null an IAE
>       will be thrown.
>       Logger.setResourceBundle requires the "control" permission.
>       When a resource bundle is set with Logger.setResourceBundle,
>       then it's that resource bundle locale that will be used
>       when logging (and not the default locale).
> I have written a set of unit tests which should cover all the points
> listed above.
> best regards,
> -- daniel

More information about the core-libs-dev mailing list