[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
Tue Nov 27 22:43:50 UTC 2018


Hi Mandy,

On 11/27/18 12:23 PM, Mandy Chung wrote:
> 
> 
> On 11/27/18 10:36 AM, naoto.sato at oracle.com wrote:
>> Comment modified as suggested:
>>
>> http://cr.openjdk.java.net/~naoto/8214170/webrev.01/
> 
> What is the exception message?  I think it's 
> "PrivateConstructorRB.<init>()" which would be confusing.
> 
> A better fix may be using getDeclaredConstructor and throw IAE if the 
> constructor is not public in the place where it currently returns null.
> 
> I think you can simply drop the comment at line 3187.

Will fix it.

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

Naoto


More information about the core-libs-dev mailing list