On 7/23/21 4:17 AM, Gunnar Morling wrote:
Thanks a lot for your replies, Mandy and Alan!

> I assume the class path is running on JDK <= 8, right? Otherwise

Is there something missing after "Otherwise"?

It was a typo (I should have taken it out).

In fact, I'm looking for a way to run this

- Java 1.8 on classpath
- Java 9+ on classpath
- Java 9+ on module path

As I've learned by now, ResourceBundleControlProvider implementations on Java 1.8 will only be loaded via the extension mechanism, which often is impractical to use. So it seems I'll need to amend my solution described above to pass in the custom Control explicitly to ResourceBundle.getBundle(). I could use the ResourceBundleControlProvider in a MR JAR, but there seems not much of an advantage to doing that.

> For the migration scenario where the resources are in .properties format then the simplest may be to just deploy the JAR files on the module path where they will be treated as automatic modules.


Right, this is indeed the simplest approach if the JAR file contain resource bundles in .properties format and no .class files in that package.  i.e. you can keep the resource bundles in `dev/morling/greeter` and deploy them as automatic modules.


In the scenario I have in mind (for educational purposes mainly) the JAR files contain the properties file as well code and should be usable as "proper" (i.e. non-automatic) modules as well as on the classpath.

It's common to have the resources packaged in separate JARs from the code and also an application includes all resources.   This educational purpose demo shows an advanced feature.


> There are no split package issues unless the resources have been compiled as .class files.

That's very interesting, it's not what I observe. Having the *.properties in one and the same package in multiple modules triggers an error upon start-up:

    java.lang.LayerInstantiationException: Package dev.morling.greeter.fr <https://urldefense.com/v3/__http://dev.morling.greeter.fr__;!!ACWV5N9M2RV99hQ!fILkGEkNjEpD7sQnRSKHS3M4qZY3lXvfXij2Q4XgaGa9P1mVdmrAFrdcvVKsPREq3A$> in both module dev.morling.greeter.german and module dev.morling.greeter.french

this looks a little suspicious.   GreetingMessages_de.properties should be expected in dev.morling.greeter.

Mandy

Reply via email to