8243596: ModuleLayer::parents should return an unmodifiable list

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

8243596: ModuleLayer::parents should return an unmodifiable list

Alan Bateman

This is an small oversight and inconsistency that crept in when the
ModuleLayer was updated to support multiple parents. The list of parent
layers returned by the parents() method should be specified (and
implemented) to return an unmodifiable list. It currently returns a
modifiable list. The equivalent Configuration::parents is correctly
specified, as is the Configuration::modules and ModuleLayer::modules
methods.

The change proposed here fixes the javadoc and implementation. The
compatibility impact is minimal as nothing could depend on being able to
dynamically change the list of parents (as it can't be changed dynamically).

I've extended the existing tests to ensure that ::modules,
Configuration::parents, ModuleLayer::modules and ModuleLayer::parents
return unmodifiable collections. In passing, there is also a typo in the
Configuration::modules where the javadoc says "immutable" instead of
"unmodifiable".

http://cr.openjdk.java.net/~alanb/8243596/webrev/

The patch doesn't update the date in the copyright headers, I'll update
those before pushing after the changes (and CSR) are agreed.

-Alan
Reply | Threaded
Open this post in threaded view
|

Re: 8243596: ModuleLayer::parents should return an unmodifiable list

Mandy Chung
On 5/5/20 12:05 PM, Alan Bateman wrote:

>
> This is an small oversight and inconsistency that crept in when the
> ModuleLayer was updated to support multiple parents. The list of
> parent layers returned by the parents() method should be specified
> (and implemented) to return an unmodifiable list. It currently returns
> a modifiable list. The equivalent Configuration::parents is correctly
> specified, as is the Configuration::modules and ModuleLayer::modules
> methods.
>
> The change proposed here fixes the javadoc and implementation. The
> compatibility impact is minimal as nothing could depend on being able
> to dynamically change the list of parents (as it can't be changed
> dynamically).
>
> I've extended the existing tests to ensure that ::modules,
> Configuration::parents, ModuleLayer::modules and ModuleLayer::parents
> return unmodifiable collections. In passing, there is also a typo in
> the Configuration::modules where the javadoc says "immutable" instead
> of "unmodifiable".
>
> http://cr.openjdk.java.net/~alanb/8243596/webrev/
>

This patch looks good.

Mandy