[12] RFR: 8214170: ResourceBundle.Control.newBundle should throw IllegalAccessException when constructor of the resource bundle is not public.

Mandy Chung mandy.chung at oracle.com
Tue Nov 27 22:55:47 UTC 2018



On 11/27/18 2:43 PM, naoto.sato at oracle.com wrote:
>
>>
>> If no-arg constructor does not exist, the javadoc does not specify 
>> its behavior (or I'm missing it?).   I believe the current behavior 
>> is consistent with JDK 8 behavior which throws 
>> NoSuchMethodException.  We should fix the spec to clarify no no-arg 
>> constructor case.
>
> The javadoc is not specifically mention for the no-arg constructor 
> case, but specifies to throw the Error/Exception wrt the instantiation 
> failure:
>
> "If a resource bundle can't be instantiated due to an unexpected 
> error, the error must be reported by throwing an Error or Exception 
> rather than simply returning null."
>
> The current behavior is inconsistent with the releases prior to JDK9, 
> as it silently ignores NoSuchMethodException and returns null, while 
> JDK8 throws IAE.

There are two cases:

1. PrivateConstructorRB has a private no-arg constructor

This is the bug this issue reports.

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).

Mandy


More information about the core-libs-dev mailing list