IllegalAccessException trying to load a ResourceBundle in 9u181

Vitaly Davidovich vitalyd at gmail.com
Mon Feb 12 20:36:59 UTC 2018


Hi all,

I'm not sure if core-libs is the right mailing list for jigsaw/modules
questions these days (rather than jigsaw-dev), so please feel free to
forward this there if it's the more appropriate list.

I have the following code carried over from java 8 (actually much earlier
than that, but that's beside the point):
final Resource rb =
ResourceBundle.getBundle("sun.security.util.AuthResources");

In 9u181, this fails with:

Exception in thread "main" java.util.MissingResourceException: Can't find
bundle for base name sun.security.util.AuthResources, locale en_US

                at java.base/java.util.ResourceBundle.
throwMissingResourceException(ResourceBundle.java:2045)

                at java.base/java.util.ResourceBundle.getBundleImpl(
ResourceBundle.java:1679)

                at java.base/java.util.ResourceBundle.getBundleImpl(
ResourceBundle.java:1583)

                at java.base/java.util.ResourceBundle.getBundleImpl(
ResourceBundle.java:1546)

                at java.base/java.util.ResourceBundle.getBundle(
ResourceBundle.java:838)

              <…>

Caused by: java.lang.IllegalAccessException: unnamed module can't load
sun.security.util.AuthResources in module java.base

                at java.base/java.util.ResourceBundle$Control.
newBundle(ResourceBundle.java:3167)

                at java.base/java.util.ResourceBundle.loadBundle(
ResourceBundle.java:1984)

                at java.base/java.util.ResourceBundle.findBundle(
ResourceBundle.java:1766)

                at java.base/java.util.ResourceBundle.findBundle(
ResourceBundle.java:1718)

                at java.base/java.util.ResourceBundle.findBundle(
ResourceBundle.java:1718)

                at java.base/java.util.ResourceBundle.getBundleImpl(
ResourceBundle.java:1652)

                ... 4 more


Not surprising given encapsulation.  So I tried running with "--add-exports
java.base/sun.security.util=ALL-UNNAMED" but that still fails, which *is*
surprising based on my understanding.  I also tried (for good measure) with
a similar add-opens but no luck there either.


I feel like I must be missing something obvious here, or doing something
silly.  What's the right way to allow the getBundle call to succeed here?


Thanks


More information about the core-libs-dev mailing list