aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/collect
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-03-16 21:50:43 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-16 21:52:35 -0700
commit04ee6ac173797d864882e840b351230324a0f1eb (patch)
treec0e588d8de9303ed2f0bfb2f11708045b44be606 /src/main/java/com/google/devtools/build/lib/collect
parent93894281b2624378abd05d8a07c498ebaf50e3af (diff)
@AutoCodec WriteZipControlFileAction (and ImmutableIterable).
Since autocodec library is now a dependency of lib/collect, properly annotate ImmutableSharedKeyMap to boot. PiperOrigin-RevId: 189432552
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/collect')
-rw-r--r--src/main/java/com/google/devtools/build/lib/collect/ImmutableIterable.java15
-rw-r--r--src/main/java/com/google/devtools/build/lib/collect/ImmutableSharedKeyMap.java5
2 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/collect/ImmutableIterable.java b/src/main/java/com/google/devtools/build/lib/collect/ImmutableIterable.java
index bd8cbe01d5..b998147bb9 100644
--- a/src/main/java/com/google/devtools/build/lib/collect/ImmutableIterable.java
+++ b/src/main/java/com/google/devtools/build/lib/collect/ImmutableIterable.java
@@ -14,17 +14,19 @@
package com.google.devtools.build.lib.collect;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Iterator;
/**
* A wrapper that signals the immutability of a certain iterable.
*
- * <p>Intended for use in scenarios when you have an iterable that is de facto immutable,
- * but is not recognized as such by {@link CollectionUtils#checkImmutable(Iterable)}.
+ * <p>Intended for use in scenarios when you have an iterable that is de facto immutable, but is not
+ * recognized as such by {@link CollectionUtils#checkImmutable(Iterable)}.
*
- * <p>Only use this when you know that the contents of the underlying iterable will never change,
- * or you will be setting yourself up for aliasing bugs.
+ * <p>Only use this when you know that the contents of the underlying iterable will never change, or
+ * you will be setting yourself up for aliasing bugs.
*/
+@AutoCodec
public final class ImmutableIterable<T> implements Iterable<T> {
private final Iterable<T> iterable;
@@ -38,10 +40,9 @@ public final class ImmutableIterable<T> implements Iterable<T> {
return iterable.iterator();
}
- /**
- * Creates an {@link ImmutableIterable} instance.
- */
+ /** Creates an {@link ImmutableIterable} instance. */
// Use a factory method in order to avoid having to specify generic arguments.
+ @AutoCodec.Instantiator
public static <T> ImmutableIterable<T> from(Iterable<T> iterable) {
return new ImmutableIterable<>(iterable);
}
diff --git a/src/main/java/com/google/devtools/build/lib/collect/ImmutableSharedKeyMap.java b/src/main/java/com/google/devtools/build/lib/collect/ImmutableSharedKeyMap.java
index 65bb4a8883..3b084c8759 100644
--- a/src/main/java/com/google/devtools/build/lib/collect/ImmutableSharedKeyMap.java
+++ b/src/main/java/com/google/devtools/build/lib/collect/ImmutableSharedKeyMap.java
@@ -19,6 +19,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Interner;
import com.google.devtools.build.lib.concurrent.BlazeInterners;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -43,8 +44,7 @@ public class ImmutableSharedKeyMap<K, V> extends CompactImmutableMap<K, V> {
private static final Interner<OffsetTable> offsetTables = BlazeInterners.newWeakInterner();
private final OffsetTable<K> offsetTable;
- // Visible only for serialization.
- protected final Object[] values;
+ @VisibleForSerialization protected final Object[] values;
private static final class OffsetTable<K> {
private final Object[] keys;
@@ -139,6 +139,7 @@ public class ImmutableSharedKeyMap<K, V> extends CompactImmutableMap<K, V> {
/** Do not use! Present only for serialization. (Annotated as @Deprecated just to prevent use.) */
@Deprecated
+ @VisibleForSerialization
public Object[] getKeys() {
return offsetTable.keys;
}