IllegalAccessException trying to load a ResourceBundle in 9u181
mandy.chung at oracle.com
Tue Feb 13 00:44:41 UTC 2018
On 2/12/18 12:36 PM, Vitaly Davidovich wrote:
> 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 =
Resource bundle follows the same encapsulation rule as described in
Module::getResourceAsStream  except that a resource bundle is
considered as a resource regardless of its format.
ResourceBundle.getBundle(String baseName) finds the specified resource
bundle from the caller's module. It will first search the resource
bundle local in the caller's module (via Module::getResourceAsStream)
and then using the caller's class loader to search for the resource (via
ClassLoader::getResourceAsStream). Since the caller is unnamed module
in your case, for it to access "sun.security.util.AuthResources",
java.base/sun.security.util has to be open unconditionally and there is
no CLI option to do that.
If you call ResourceBundle.getBundle("sun.security.util.AuthResources",
Object.class.getModule()) specifying the module of the resource bundle,
then you can break the encapsulation by `--add-opens
I'm a bit surprised that you depend on JDK internal resource bundle.
Can you help us understand why you use it?
More information about the core-libs-dev