mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8243596: ModuleLayer::parents should return an unmodifiable list
Reviewed-by: mchung
This commit is contained in:
parent
93b0516d5d
commit
f6dda95113
4 changed files with 90 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -489,7 +489,7 @@ public final class ModuleLayer {
|
|||
List<ModuleLayer> parentLayers,
|
||||
ClassLoader parentLoader)
|
||||
{
|
||||
List<ModuleLayer> parents = new ArrayList<>(parentLayers);
|
||||
List<ModuleLayer> parents = List.copyOf(parentLayers);
|
||||
checkConfiguration(cf, parents);
|
||||
|
||||
checkCreateClassLoaderPermission();
|
||||
|
@ -565,7 +565,7 @@ public final class ModuleLayer {
|
|||
List<ModuleLayer> parentLayers,
|
||||
ClassLoader parentLoader)
|
||||
{
|
||||
List<ModuleLayer> parents = new ArrayList<>(parentLayers);
|
||||
List<ModuleLayer> parents = List.copyOf(parentLayers);
|
||||
checkConfiguration(cf, parents);
|
||||
|
||||
checkCreateClassLoaderPermission();
|
||||
|
@ -649,7 +649,7 @@ public final class ModuleLayer {
|
|||
List<ModuleLayer> parentLayers,
|
||||
Function<String, ClassLoader> clf)
|
||||
{
|
||||
List<ModuleLayer> parents = new ArrayList<>(parentLayers);
|
||||
List<ModuleLayer> parents = List.copyOf(parentLayers);
|
||||
checkConfiguration(cf, parents);
|
||||
Objects.requireNonNull(clf);
|
||||
|
||||
|
@ -752,13 +752,12 @@ public final class ModuleLayer {
|
|||
return cf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the list of this layer's parents unless this is the
|
||||
* {@linkplain #empty empty layer}, which has no parents and so an
|
||||
* Returns an unmodifiable list of this layer's parents, in search
|
||||
* order. If this is the {@linkplain #empty() empty layer} then an
|
||||
* empty list is returned.
|
||||
*
|
||||
* @return The list of this layer's parents
|
||||
* @return A possibly-empty unmodifiable list of this layer's parents
|
||||
*/
|
||||
public List<ModuleLayer> parents() {
|
||||
return parents;
|
||||
|
@ -803,7 +802,7 @@ public final class ModuleLayer {
|
|||
private volatile List<ModuleLayer> allLayers;
|
||||
|
||||
/**
|
||||
* Returns the set of the modules in this layer.
|
||||
* Returns an unmodifiable set of the modules in this layer.
|
||||
*
|
||||
* @return A possibly-empty unmodifiable set of the modules in this layer
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue