diff options
author | 2017-08-09 15:20:02 +0200 | |
---|---|---|
committer | 2017-08-10 13:38:57 +0200 | |
commit | 6b2dce6710ed7d2429e0e3dc113c9bad622b8c4b (patch) | |
tree | 2060ac8fbb988503e09be731bd3abd6de8ccfebb | |
parent | fb20d20580456280b0e64162fdbe86dafca75388 (diff) |
In the MutableList API, make an internal unsafe method public
This method acts as an "escape hatch" for mutating a list regardless of Mutability. It should be avoided if at all possible.
RELNOTES: None
PiperOrigin-RevId: 164716286
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java index bab6df740a..1f90a65c51 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java @@ -335,8 +335,17 @@ public abstract class SkylarkList<E> extends BaseMutableList<E> ImmutableList.copyOf(contents), env == null ? null : env.mutability()); } - /** Appends the given elements to the end of the list, without calling {@link #checkMutable}. */ - private void addAllUnsafe(Iterable<? extends E> elements) { + /** + * Appends the given elements to the end of the list, without calling {@link #checkMutable}. + * + * <p><em>Warning:</em> This method should never be used by a caller that cares about respecting + * mutability restrictions. Such callers should instead use the safe {@link #addAll(Iterable, + * Location, Mutability)} method below. This unsafe variant is only public in order to provide + * an "escape hatch" for when ordinary mutability restrictions are inapplicable, e.g. for + * constructing lists from outside a Skylark environment and where it's impossible for multiple + * threads to observe the value at once. + */ + public void addAllUnsafe(Iterable<? extends E> elements) { Iterables.addAll(contents, elements); } |