Changed behaviour of ResourceBundle#getBundle()

Gunnar Morling gunnar at
Mon Dec 12 15:29:32 UTC 2016

Hi Alan,

I noticed the changed behaviour in the context of Bean Validation, but I
observe the same in an isolated test case. The bundle is not within

The following will print out the entry from "mybundle" in module "b",
although requesting the resource bundle from within "a":

mkdir -p sources/com.example.a/src/main/java/com/example/a/
mkdir -p sources/com.example.b/src/main/java/
mkdir -p sources/com.example.b/src/main/resources/

cat >
<< EOF
package com.example.a;

public class ResourceBundleTest {

    public static void main(String... args) {
        String value =

echo "module com.example.a { exports com.example.a; }" >

echo "mykey=Hello World" >
echo "module com.example.b {}" >

cd sources/com.example.a && javac -g -d ../../modules/com.example.a $(find
src/main/java -name "*.java") && cd ../..
cd sources/com.example.b && javac -g -d ../../modules/com.example.b $(find
src/main/java -name "*.java") && cp -r src/main/resources/*
../../modules/com.example.b && cd ../..
java --module-path modules --add-modules com.example.b -m

It seems to be related to the fact that the bundle is located in the
default package, because the expected exception is raised if the bundle is
located in a proper package.


2016-12-12 14:54 GMT+01:00 Alan Bateman <Alan.Bateman at>:

> On 12/12/2016 13:38, Gunnar Morling wrote:
> Hi,
>> I'm about to update my blog post on Bean Validation and Jigsaw from a
>> while
>> ago [1] to the latest JDK 9 build.
>> There is one behavioural change that made me curious:
>> ResourceBundle#getBundle() called from within named module "A" now (as of
>> b148) returns a bundle based on a properties file located in another named
>> module "B". "A" does not require "B" in it's, nor does
>> "B"
>> export any packages at all. This was not the case when I originally tried
>> it (b122).
> The latest JDK 9 does have the updated proposal for #ResourceEncapsulation
> and ResourceBundle has been updated to align with that proposal.
> You mention Bean Validation. Does this mean the properties file is in
> META-INF? If so then it will not be encapsulated because "META-INF" is not
> a legacl package name.
> -Alan

More information about the jigsaw-dev mailing list