diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainTool.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainTool.java index b3605151023134..9bdc734a26c8c2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainTool.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainTool.java @@ -32,8 +32,16 @@ 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.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.util.Pair; import com.google.devtools.build.lib.vfs.PathFragment; +import com.google.errorprone.annotations.Keep; +import com.google.protobuf.CodedInputStream; +import com.google.protobuf.CodedOutputStream; +import java.io.IOException; import javax.annotation.Nullable; /** An executable tool that is part of {@code java_toolchain}. */ @@ -156,4 +164,28 @@ void addInputs(JavaToolchainProvider toolchain, NestedSetBuilder input inputs.add(executable).addTransitive(toolchain.getJavaRuntime().javaBaseInputs()); } } + + @Keep // Accessed reflectively. + private static class Codec implements ObjectCodec { + @Override + public Class getEncodedClass() { + return JavaToolchainTool.class; + } + + @Override + public void serialize( + SerializationContext context, JavaToolchainTool obj, CodedOutputStream codedOut) + throws SerializationException, IOException { + context.serialize(obj.tool(), codedOut); + context.serialize(obj.data(), codedOut); + context.serialize(obj.jvmOpts(), codedOut); + } + + @Override + public JavaToolchainTool deserialize(DeserializationContext context, CodedInputStream codedIn) + throws SerializationException, IOException { + return create( + context.deserialize(codedIn), context.deserialize(codedIn), context.deserialize(codedIn)); + } + } }