8243596: ModuleLayer::parents should return an unmodifiable list
Mandy Chung
mandy.chung at oracle.com
Tue May 5 22:16:29 UTC 2020
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
More information about the jigsaw-dev
mailing list