[12] RFR: 8214170: ResourceBundle.Control.newBundle should throw IllegalAccessException when constructor of the resource bundle is not public.
naoto.sato at oracle.com
naoto.sato at oracle.com
Thu Nov 29 17:08:59 UTC 2018
Hi,
I updated the webrev, incorporating Mandy's suggestions. Please review.
http://cr.openjdk.java.net/~naoto/8214170/webrev.02/
Naoto
On 11/28/18 5:56 AM, naoto.sato at oracle.com wrote:
> Thank you, Mandy, for pointing out. I was wrong on JDK8 result. With a
> modified test case, I got the following result for jdk8 and jdk12:
>
> jdk8u:
>
> slc06brs:/projects/jdk/jdk/jdk/open/test/jdk/java/util/ResourceBundle/Control
> 479 %
> /projects/jdk/8/jdk8u-dev/build/linux-x86_64-normal-server-fastdebug/jdk/bin/java
> MissingResourceCauseTest
> Exception in thread "main" java.lang.RuntimeException:
> getBundle("PrivateConstructorRB") throws
> java.lang.InstantiationException: PrivateConstructorRB, expected class
> java.lang.IllegalAccessException
> at
> MissingResourceCauseTest.callGetBundle(MissingResourceCauseTest.java:56)
> at
> MissingResourceCauseTest.callGetBundle(MissingResourceCauseTest.java:43)
> at MissingResourceCauseTest.main(MissingResourceCauseTest.java:34)
>
>
> jdk12:
>
> slc06brs:/projects/jdk/jdk/newera/open/test/jdk/java/util/ResourceBundle/Control
> 488 % /projects/jdk/jdk/newera/build/linux-x64/jdk/bin/java
> MissingResourceCauseTest
> Exception in thread "main" java.lang.RuntimeException:
> getBundle("PrivateConstructorRB") throws null, expected class
> java.lang.IllegalAccessException
> at
> MissingResourceCauseTest.callGetBundle(MissingResourceCauseTest.java:55)
> at
> MissingResourceCauseTest.callGetBundle(MissingResourceCauseTest.java:42)
> at MissingResourceCauseTest.main(MissingResourceCauseTest.java:34)
>
> So, for missing no-arg constructor, jdk8 throws MissingResourceException
> with InstantiationException as the cause, and jdk12 throws
> MissingResourceException with the "null" cause.
>
> Naoto
>
> On 11/27/18 3:41 PM, naoto.sato at oracle.com wrote:
>>> 2. PrivateConstructorRB does not have any no-arg constructor (you
>>> have to create a new test case for it)
>>>
>>> I believe the behavior is not changed in JDK 9. It throws
>>> NoSuchMethodException (not ignored).
>>
>> In this case, the behavior is not changed. However, it does not throw
>> NoSuchMethodException from newBundle(), both in JDK8 and current. It
>> simply returns null, and the cause in the resulting
>> MissingResourceException is "null".
>>
>> Naoto
More information about the core-libs-dev
mailing list