Skip to content

Commit

Permalink
Delete non-interning, non-singleton @AutoCodec.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 411683398
  • Loading branch information
Googler authored and copybara-github committed Nov 23, 2021
1 parent a882f87 commit 7f74878
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.util.Fingerprint;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -44,7 +43,6 @@
* action cache), such that Bazel knows exactly which actions it needs to rerun, and does not have
* to reanalyze the entire dependency graph.
*/
@AutoCodec
public final class ActionEnvironment {

/** A map of environment variables. */
Expand Down Expand Up @@ -163,8 +161,7 @@ private ActionEnvironment(EnvironmentVariables fixedEnv, ImmutableSet<String> in
* undefined, so callers need to take care that the key set of the {@code fixedEnv} map and the
* set of {@code inheritedEnv} elements are disjoint.
*/
@AutoCodec.Instantiator
public static ActionEnvironment create(
private static ActionEnvironment create(
EnvironmentVariables fixedEnv, ImmutableSet<String> inheritedEnv) {
if (fixedEnv.isEmpty() && inheritedEnv.isEmpty()) {
return EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
import com.google.devtools.build.lib.buildeventstream.BuildEventContext;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Collection;
import java.util.Objects;

/**
* Encapsulation of {@link BuildEvent} info associated with a {@link
* com.google.devtools.build.lib.analysis.config.BuildConfigurationValue}.
*/
@AutoCodec
public class BuildConfigurationEvent implements BuildEvent {
public final class BuildConfigurationEvent implements BuildEvent {

private final BuildEventId eventId;
private final BuildEventStreamProtos.BuildEvent eventProto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
import com.google.common.collect.Maps;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Collection;
import java.util.Map;

/** A {@link RunfilesSupplier} implementation for composing multiple instances. */
@AutoCodec
public class CompositeRunfilesSupplier implements RunfilesSupplier {
public final class CompositeRunfilesSupplier implements RunfilesSupplier {

private final ImmutableList<RunfilesSupplier> suppliers;

Expand Down Expand Up @@ -59,9 +57,7 @@ public static RunfilesSupplier of(RunfilesSupplier supplier1, RunfilesSupplier s
/**
* Create an instance combining all of {@code suppliers}, with earlier elements taking precedence.
*/
@AutoCodec.Instantiator
@AutoCodec.VisibleForSerialization
CompositeRunfilesSupplier(ImmutableList<RunfilesSupplier> suppliers) {
private CompositeRunfilesSupplier(ImmutableList<RunfilesSupplier> suppliers) {
this.suppliers = suppliers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Map;

/** Empty implementation of RunfilesSupplier */
public final class EmptyRunfilesSupplier implements RunfilesSupplier {

@AutoCodec public static final EmptyRunfilesSupplier INSTANCE = new EmptyRunfilesSupplier();
@SerializationConstant
public static final EmptyRunfilesSupplier INSTANCE = new EmptyRunfilesSupplier();

private EmptyRunfilesSupplier() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import com.google.devtools.build.lib.util.Fingerprint;
import javax.annotation.Nullable;

Expand All @@ -33,15 +31,12 @@
* the action graph; for example generated header files.
*/
@Immutable
@AutoCodec
public final class MiddlemanAction extends AbstractAction {
public static final String MIDDLEMAN_MNEMONIC = "Middleman";
private final String description;
private final MiddlemanType middlemanType;

@VisibleForSerialization
@AutoCodec.Instantiator
MiddlemanAction(
private MiddlemanAction(
ActionOwner owner,
NestedSet<Artifact> inputs,
ImmutableSet<Artifact> outputs,
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,6 @@ java_library(
deps = [
":config/fragment",
"//src/main/java/com/google/devtools/build/lib/concurrent",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:serialization-constant",
"//src/main/java/com/google/devtools/build/lib/util",
"//third_party:guava",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.collect.Interner;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.concurrent.BlazeInterners;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
import com.google.devtools.build.lib.util.ClassName;
import java.util.AbstractSet;
Expand All @@ -35,7 +34,6 @@
* objects allows us to do cheap reference equality checks when these sets are in frequently used
* keys.
*/
@AutoCodec
@Immutable
public final class FragmentClassSet extends AbstractSet<Class<? extends Fragment>> {

Expand All @@ -49,7 +47,6 @@ public final class FragmentClassSet extends AbstractSet<Class<? extends Fragment

private static final Interner<FragmentClassSet> interner = BlazeInterners.newWeakInterner();

@AutoCodec.Instantiator
public static FragmentClassSet of(Collection<Class<? extends Fragment>> fragments) {
ImmutableSortedSet<Class<? extends Fragment>> sortedFragments =
ImmutableSortedSet.copyOf(LEXICAL_FRAGMENT_SORTER, fragments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.google.devtools.build.lib.packages.ConfigurationFragmentPolicy.MissingFragmentPolicy;
import com.google.devtools.build.lib.packages.Type.LabelClass;
import com.google.devtools.build.lib.packages.Type.LabelVisitor;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -61,7 +60,6 @@
* <p>The way to build the Skyframe node is not here because this data needs to be accessible from
* the {@code .packages} package and that one requires references to the {@code .view} package.
*/
@AutoCodec
@Immutable
public final class AspectDefinition {
private final AspectClass aspectClass;
Expand Down Expand Up @@ -99,8 +97,7 @@ public AdvertisedProviderSet getAdvertisedProviders() {
return advertisedProviders;
}

@AutoCodec.VisibleForSerialization
AspectDefinition(
private AspectDefinition(
AspectClass aspectClass,
AdvertisedProviderSet advertisedProviders,
RequiredProviders requiredProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Objects;

/**
* Objects of this class contain values of some attributes of rules. Used for passing this
* information to the aspects.
*/
@AutoCodec
public final class AspectParameters {
private final ImmutableMultimap<String, String> attributes;

Expand All @@ -35,9 +33,7 @@ private AspectParameters(Multimap<String, String> attributes) {

public static final AspectParameters EMPTY = new AspectParameters(ImmutableMultimap.of());

@AutoCodec.Instantiator
@AutoCodec.VisibleForSerialization
static AspectParameters create(ImmutableMultimap<String, String> attributes) {
private static AspectParameters create(ImmutableMultimap<String, String> attributes) {
if (attributes.isEmpty()) {
return EMPTY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.google.devtools.build.lib.packages;

import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.util.Fingerprint;
import javax.annotation.Nullable;
import net.starlark.java.eval.Printer;
Expand Down Expand Up @@ -110,7 +109,6 @@ public interface WithLegacyStarlarkName {
}

/** A serializable reference to a {@link BuiltinProvider}. */
@AutoCodec
@Immutable
public static final class Key extends Provider.Key {
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
Expand All @@ -37,8 +36,7 @@
* mutability of fulfillersMap means that we must take care to wait until it is set before doing
* anything with this class.
*/
@AutoCodec
public class EnvironmentLabels {
public final class EnvironmentLabels {
final Label label;
final ImmutableSet<Label> environments;
final ImmutableSet<Label> defaults;
Expand All @@ -57,9 +55,7 @@ public class EnvironmentLabels {
* Only for use by serialization: the mutable fulfillersMap object is not properly initialized
* otherwise during deserialization.
*/
@AutoCodec.VisibleForSerialization
@AutoCodec.Instantiator
EnvironmentLabels(
private EnvironmentLabels(
Label label,
Collection<Label> environments,
Collection<Label> defaults,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import com.google.devtools.build.lib.starlarkbuildapi.LicenseApi;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -35,7 +33,6 @@
/** Support for license and distribution checking. */
@Immutable
@ThreadSafe
@AutoCodec
public final class License implements LicenseApi {
private final ImmutableSet<LicenseType> licenseTypes;
private final ImmutableSet<Label> exceptions;
Expand Down Expand Up @@ -131,9 +128,7 @@ public static Set<DistributionType> parseDistributions(Collection<String> distSt
}
}

@AutoCodec.Instantiator
@VisibleForSerialization
License(ImmutableSet<LicenseType> licenseTypes, ImmutableSet<Label> exceptions) {
private License(ImmutableSet<LicenseType> licenseTypes, ImmutableSet<Label> exceptions) {
// Defensive copy is done in .of()
this.licenseTypes = licenseTypes;
this.exceptions = exceptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
// limitations under the License.
package com.google.devtools.build.lib.packages;

import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;

/**
* A helper class for PredicateWithMessage with default predicates.
*/
public abstract class PredicatesWithMessage implements PredicateWithMessage<Object> {

@AutoCodec @VisibleForSerialization
@SerializationConstant @VisibleForSerialization
static final PredicateWithMessage<?> ALWAYS_TRUE =
new PredicateWithMessage<Object>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import java.util.Objects;
import java.util.function.Function;
Expand All @@ -41,7 +40,6 @@
* </ul>
*/
@Immutable
@AutoCodec
public final class RequiredProviders {
/** A constraint: either ANY, NONE, or RESTRICTED */
private final Constraint constraint;
Expand Down

0 comments on commit 7f74878

Please sign in to comment.