Deletes CODEC fields now that they are no longer needed.

PiperOrigin-RevId: 187397314
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
index 5adb947..f271ea6 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
@@ -22,6 +22,7 @@
 import com.google.devtools.build.lib.concurrent.BlazeInterners;
 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.skylarkinterface.Param;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
@@ -51,6 +52,7 @@
   category = SkylarkModuleCategory.BUILTIN,
   doc = "A BUILD target identifier."
 )
+@AutoCodec
 @Immutable
 @ThreadSafe
 public final class Label
@@ -81,8 +83,6 @@
   public static final SkyFunctionName TRANSITIVE_TRAVERSAL =
       SkyFunctionName.create("TRANSITIVE_TRAVERSAL");
 
-  public static final LabelCodec CODEC = LabelCodec.INSTANCE;
-
   private static final Interner<Label> LABEL_INTERNER = BlazeInterners.newWeakInterner();
 
   /**
@@ -185,10 +185,11 @@
    * Similar factory to above, but does not perform target name validation.
    *
    * <p>Only call this method if you know what you're doing; in particular, don't call it on
-   * arbitrary {@code targetName} inputs
+   * arbitrary {@code name} inputs
    */
-  public static Label createUnvalidated(PackageIdentifier packageId, String targetName) {
-    return LABEL_INTERNER.intern(new Label(packageId, targetName));
+  @AutoCodec.Instantiator
+  public static Label createUnvalidated(PackageIdentifier packageIdentifier, String name) {
+    return LABEL_INTERNER.intern(new Label(packageIdentifier, name));
   }
 
   /**
@@ -290,7 +291,7 @@
     return new LabelSerializationProxy(getUnambiguousCanonicalForm());
   }
 
-  private void readObject(ObjectInputStream stream) throws InvalidObjectException {
+  private void readObject(ObjectInputStream unusedStream) throws InvalidObjectException {
     throw new InvalidObjectException("Serialization is allowed only by proxy");
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/LabelCodec.java b/src/main/java/com/google/devtools/build/lib/cmdline/LabelCodec.java
deleted file mode 100644
index 4153d5e..0000000
--- a/src/main/java/com/google/devtools/build/lib/cmdline/LabelCodec.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.cmdline;
-
-import com.google.devtools.build.lib.skyframe.serialization.DeserializationContext;
-import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
-import com.google.devtools.build.lib.skyframe.serialization.SerializationContext;
-import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
-import com.google.devtools.build.lib.skyframe.serialization.strings.StringCodecs;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization logic for {@link Label}s. */
-public class LabelCodec implements ObjectCodec<Label> {
-  public static final LabelCodec INSTANCE = new LabelCodec();
-
-  // TODO(michajlo): Share single instance of package id codec among all the codecs.
-  private final PackageIdentifierCodec packageIdCodec = new PackageIdentifierCodec();
-  private final ObjectCodec<String> stringCodec = StringCodecs.asciiOptimized();
-
-  @Override
-  public Class<Label> getEncodedClass() {
-    return Label.class;
-  }
-
-  @Override
-  public void serialize(SerializationContext context, Label label, CodedOutputStream codedOut)
-      throws IOException, SerializationException {
-    packageIdCodec.serialize(context, label.getPackageIdentifier(), codedOut);
-    stringCodec.serialize(context, label.getName(), codedOut);
-  }
-
-  @Override
-  public Label deserialize(DeserializationContext context, CodedInputStream codedIn)
-      throws SerializationException, IOException {
-    PackageIdentifier packageId = packageIdCodec.deserialize(context, codedIn);
-    String name = stringCodec.deserialize(context, codedIn);
-    return Label.createUnvalidated(packageId, name);
-  }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
index fdf574f..d8bf3bf 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
@@ -18,7 +18,7 @@
 import com.google.common.collect.ComparisonChain;
 import com.google.common.collect.Interner;
 import com.google.devtools.build.lib.concurrent.BlazeInterners;
-import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -33,12 +33,10 @@
  * the workspace name "". Other repositories can be named in the WORKSPACE file. These workspaces
  * are prefixed by {@literal @}.
  */
+@AutoCodec
 @Immutable
 public final class PackageIdentifier
     implements Comparable<PackageIdentifier>, Serializable, SkylarkValue {
-
-  public static final ObjectCodec<PackageIdentifier> CODEC = new PackageIdentifierCodec();
-
   private static final Interner<PackageIdentifier> INTERNER = BlazeInterners.newWeakInterner();
 
   public static PackageIdentifier create(String repository, PathFragment pkgName)
@@ -46,6 +44,7 @@
     return create(RepositoryName.create(repository), pkgName);
   }
 
+  @AutoCodec.Instantiator
   public static PackageIdentifier create(RepositoryName repository, PathFragment pkgName) {
     return INTERNER.intern(new PackageIdentifier(repository, pkgName));
   }
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifierCodec.java b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifierCodec.java
deleted file mode 100644
index 1dcb78f..0000000
--- a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifierCodec.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.cmdline;
-
-import com.google.devtools.build.lib.skyframe.serialization.DeserializationContext;
-import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
-import com.google.devtools.build.lib.skyframe.serialization.SerializationContext;
-import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
-import com.google.devtools.build.lib.vfs.PathFragment;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
-
-/** Custom serialization logic for {@link PackageIdentifier}s. */
-public class PackageIdentifierCodec implements ObjectCodec<PackageIdentifier> {
-
-  private final RepositoryNameCodec repoNameCodec = new RepositoryNameCodec();
-
-  @Override
-  public Class<PackageIdentifier> getEncodedClass() {
-    return PackageIdentifier.class;
-  }
-
-  @Override
-  public void serialize(
-      SerializationContext context, PackageIdentifier pkgId, CodedOutputStream codedOut)
-      throws IOException, SerializationException {
-    repoNameCodec.serialize(context, pkgId.getRepository(), codedOut);
-    PathFragment.CODEC.serialize(context, pkgId.getPackageFragment(), codedOut);
-  }
-
-  @Override
-  public PackageIdentifier deserialize(DeserializationContext context, CodedInputStream codedIn)
-      throws IOException, SerializationException {
-    RepositoryName repoName = repoNameCodec.deserialize(context, codedIn);
-    PathFragment pathFragment = PathFragment.CODEC.deserialize(context, codedIn);
-    return PackageIdentifier.create(repoName, pathFragment);
-  }
-}