Loading resource bundles across module boundaries

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Loading resource bundles across module boundaries

Nicolai Parlog
 Hi!

The ResourceBundle Javadoc[1] says:

> * Code in a named module that calls getBundle(String, Locale)
>   will locate resource bundles in the caller's module (caller module).
> * If resource bundles are deployed in named modules separate from the
>   caller module, those resource bundles need to be loaded from service
>   providers of ResourceBundleProvider.

I interpreted this to mean that, without registering services, named
modules can only load bundles from themselves. But in my experiments I
could also load resource bundles from other modules as long as the
package containing them was open.

Did I make a mistake? Did I misinterpret the Javadoc? Is that behavior
buggy?

 so long ... Nicolai


[1] https://docs.oracle.com/javase/9/docs/api/java/util/ResourceBundle.html



--

PGP Key:
    http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509

Web:
    http://codefx.org
        a blog about software development
    https://www.sitepoint.com/java
        high-quality Java/JVM content
    http://do-foss.de
        Free and Open Source Software for the City of Dortmund

Twitter:
    https://twitter.com/nipafx
Reply | Threaded
Open this post in threaded view
|

Re: Loading resource bundles across module boundaries

Alan Bateman


On 11/02/2018 15:31, Nicolai Parlog wrote:
> :
> I interpreted this to mean that, without registering services, named
> modules can only load bundles from themselves. But in my experiments I
> could also load resource bundles from other modules as long as the
> package containing them was open.
>
> Did I make a mistake? Did I misinterpret the Javadoc? Is that behavior
> buggy?
>
The behavior is correct but isn't clearly covered in the Java SE 9
javadoc. Mandy has improved the javadoc for Java SE 10 [1] so it's much
clearer and covers all the scenarios.

-Alan

[1]
https://download.java.net/java/jdk10/docs/api/java/util/ResourceBundle.html
Reply | Threaded
Open this post in threaded view
|

Re: Loading resource bundles across module boundaries

Nicolai Parlog
No matter what I do, there's always one document I didn't look at. :/

As usual, thank you very much!


On 11.02.2018 21:48, Alan Bateman wrote:

>
>
> On 11/02/2018 15:31, Nicolai Parlog wrote:
>> :
>> I interpreted this to mean that, without registering services, named
>> modules can only load bundles from themselves. But in my experiments I
>> could also load resource bundles from other modules as long as the
>> package containing them was open.
>>
>> Did I make a mistake? Did I misinterpret the Javadoc? Is that behavior
>> buggy?
>>
> The behavior is correct but isn't clearly covered in the Java SE 9
> javadoc. Mandy has improved the javadoc for Java SE 10 [1] so it's much
> clearer and covers all the scenarios.
>
> -Alan
>
> [1]
> https://download.java.net/java/jdk10/docs/api/java/util/ResourceBundle.html
>

--

PGP Key:
    http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509

Web:
    http://codefx.org
        a blog about software development
    https://www.sitepoint.com/java
        high-quality Java/JVM content
    http://do-foss.de
        Free and Open Source Software for the City of Dortmund

Twitter:
    https://twitter.com/nipafx