From 743e24b5b943d74d49f815e62d0ebc38160af5b7 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 26 Dec 2023 14:49:58 -0800 Subject: [PATCH] Update LeafObjectCodec to allow use of SerializationDependencyProvider. This is useful in a couple of places and doesn't break any asynchrony requirements. PiperOrigin-RevId: 593860553 Change-Id: I9946cb13a522b655445f26ef5ee7d93592bfe67e --- .../serialization/BigIntegerCodec.java | 7 +++++-- .../skyframe/serialization/BitSetCodec.java | 11 +++++++---- .../skyframe/serialization/BooleanCodec.java | 7 +++++-- .../skyframe/serialization/ByteArrayCodec.java | 7 +++++-- .../serialization/ByteStringCodec.java | 7 +++++-- .../lib/skyframe/serialization/ClassCodec.java | 11 +++++++---- .../serialization/CodecWithFailure.java | 7 +++++-- .../skyframe/serialization/DoubleCodec.java | 7 +++++-- .../skyframe/serialization/DurationCodec.java | 7 +++++-- .../skyframe/serialization/EmptyListCodec.java | 8 ++++++-- .../lib/skyframe/serialization/EnumCodec.java | 7 +++++-- .../skyframe/serialization/HashCodeCodec.java | 7 +++++-- .../skyframe/serialization/IntegerCodec.java | 7 +++++-- .../serialization/LeafObjectCodec.java | 18 ++++++++++-------- .../skyframe/serialization/LongArrayCodec.java | 7 +++++-- .../lib/skyframe/serialization/LongCodec.java | 7 +++++-- .../serialization/MessageLiteCodec.java | 7 +++++-- .../skyframe/serialization/MethodCodec.java | 18 ++++++++++-------- .../skyframe/serialization/SingletonCodec.java | 7 +++++-- .../lib/skyframe/serialization/UUIDCodec.java | 7 +++++-- .../strings/UnsafeStringCodec.java | 7 +++++-- .../devtools/build/lib/vfs/PathFragment.java | 11 +++++++---- 22 files changed, 127 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java index 8ac5b9d1f2b789..94d26547304047 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java @@ -27,12 +27,15 @@ public Class getEncodedClass() { } @Override - public void serialize(BigInteger obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, BigInteger obj, CodedOutputStream codedOut) + throws IOException { codedOut.writeByteArrayNoTag(obj.toByteArray()); } @Override - public BigInteger deserialize(CodedInputStream codedIn) + public BigInteger deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws SerializationException, IOException { return new BigInteger(codedIn.readByteArray()); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BitSetCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BitSetCodec.java index f9fbe889b2cac3..8a6bfec97acc92 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BitSetCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BitSetCodec.java @@ -28,13 +28,16 @@ public Class getEncodedClass() { } @Override - public void serialize(BitSet obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, BitSet obj, CodedOutputStream codedOut) + throws IOException { long[] data = obj.toLongArray(); - DELEGATE.serialize(data, codedOut); + DELEGATE.serialize(dependencies, data, codedOut); } @Override - public BitSet deserialize(CodedInputStream codedIn) throws IOException { - return BitSet.valueOf(DELEGATE.deserialize(codedIn)); + public BitSet deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { + return BitSet.valueOf(DELEGATE.deserialize(dependencies, codedIn)); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java index 59a70e9c398911..ec45613b2dc4a9 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BooleanCodec.java @@ -27,12 +27,15 @@ public Class getEncodedClass() { } @Override - public void serialize(Boolean value, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, Boolean value, CodedOutputStream codedOut) + throws IOException { codedOut.writeBoolNoTag(value); } @Override - public Boolean deserialize(CodedInputStream codedIn) throws IOException { + public Boolean deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { return codedIn.readBool(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteArrayCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteArrayCodec.java index 63567ba57646fd..744ab45502c0d0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteArrayCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteArrayCodec.java @@ -26,12 +26,15 @@ public Class getEncodedClass() { } @Override - public void serialize(byte[] obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, byte[] obj, CodedOutputStream codedOut) + throws IOException { codedOut.writeByteArrayNoTag(obj); } @Override - public byte[] deserialize(CodedInputStream codedIn) throws IOException { + public byte[] deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { return codedIn.readByteArray(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteStringCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteStringCodec.java index 373548ec066392..b421058eda1cbf 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteStringCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ByteStringCodec.java @@ -28,12 +28,15 @@ public Class getEncodedClass() { } @Override - public void serialize(ByteString obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, ByteString obj, CodedOutputStream codedOut) + throws IOException { codedOut.writeBytesNoTag(obj); } @Override - public ByteString deserialize(CodedInputStream codedIn) throws IOException { + public ByteString deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws IOException { return codedIn.readBytes(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ClassCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ClassCodec.java index 323bf2fcd06fc4..af85302da9f0fc 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ClassCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/ClassCodec.java @@ -31,23 +31,26 @@ public Class> getEncodedClass() { } @Override - public void serialize(Class obj, CodedOutputStream codedOut) + public void serialize( + SerializationDependencyProvider dependencies, Class obj, CodedOutputStream codedOut) throws SerializationException, IOException { codedOut.writeBoolNoTag(obj.isPrimitive()); if (obj.isPrimitive()) { codedOut.writeInt32NoTag(Preconditions.checkNotNull(PRIMITIVE_CLASS_INDEX_MAP.get(obj), obj)); } else { - stringCodec().serialize(obj.getName(), codedOut); + stringCodec().serialize(dependencies, obj.getName(), codedOut); } } @Override - public Class deserialize(CodedInputStream codedIn) throws SerializationException, IOException { + public Class deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException, IOException { boolean isPrimitive = codedIn.readBool(); if (isPrimitive) { return PRIMITIVE_CLASS_INDEX_MAP.inverse().get(codedIn.readInt32()); } - String className = stringCodec().deserialize(codedIn); + String className = stringCodec().deserialize(dependencies, codedIn); try { return Class.forName(className); } catch (ClassNotFoundException e) { diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/CodecWithFailure.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/CodecWithFailure.java index ce5a3d75f0c452..ea9199861b41b1 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/CodecWithFailure.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/CodecWithFailure.java @@ -37,12 +37,15 @@ public Class getEncodedClass() { } @Override - public void serialize(T obj, CodedOutputStream codedOut) throws SerializationException { + public void serialize( + SerializationDependencyProvider dependencies, T obj, CodedOutputStream codedOut) + throws SerializationException { throw new SerializationException(message); } @Override - public T deserialize(CodedInputStream codedIn) throws SerializationException { + public T deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException { throw new SerializationException(message); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DoubleCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DoubleCodec.java index 39cdae28f04960..1d5dbd38707876 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DoubleCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DoubleCodec.java @@ -26,12 +26,15 @@ public Class getEncodedClass() { } @Override - public void serialize(Double value, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, Double value, CodedOutputStream codedOut) + throws IOException { codedOut.writeDoubleNoTag(value); } @Override - public Double deserialize(CodedInputStream codedIn) throws IOException { + public Double deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { return codedIn.readDouble(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DurationCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DurationCodec.java index 629e35b3da1c14..b15896b9744656 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DurationCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/DurationCodec.java @@ -22,13 +22,16 @@ /** Encodes a Duration. */ public class DurationCodec extends LeafObjectCodec { @Override - public void serialize(Duration obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, Duration obj, CodedOutputStream codedOut) + throws IOException { codedOut.writeInt64NoTag(obj.getSeconds()); codedOut.writeInt32NoTag(obj.getNano()); } @Override - public Duration deserialize(CodedInputStream codedIn) throws IOException { + public Duration deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws IOException { return Duration.ofSeconds(codedIn.readInt64(), codedIn.readInt32()); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EmptyListCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EmptyListCodec.java index 31ba7789f8dc28..a20f6465702203 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EmptyListCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EmptyListCodec.java @@ -34,10 +34,14 @@ public Class getEncodedClass() { } @Override - public void serialize(List unusedValue, CodedOutputStream unusedCodedOut) {} + public void serialize( + SerializationDependencyProvider dependencies, + List unusedValue, + CodedOutputStream unusedCodedOut) {} @Override - public List deserialize(CodedInputStream unusedCodedIn) { + public List deserialize( + SerializationDependencyProvider dependencies, CodedInputStream unusedCodedIn) { return Collections.emptyList(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EnumCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EnumCodec.java index bd21a08b9a8362..a877e597902aa1 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EnumCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/EnumCodec.java @@ -41,13 +41,16 @@ public Class getEncodedClass() { } @Override - public void serialize(T value, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, T value, CodedOutputStream codedOut) + throws IOException { Preconditions.checkNotNull(value, "Enum value for %s is null", enumClass); codedOut.writeEnumNoTag(value.ordinal()); } @Override - public T deserialize(CodedInputStream codedIn) throws SerializationException, IOException { + public T deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException, IOException { int ordinal = codedIn.readEnum(); try { return values.get(ordinal); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/HashCodeCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/HashCodeCodec.java index 7fae39d8d32575..30c146f5ed7d2e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/HashCodeCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/HashCodeCodec.java @@ -23,12 +23,15 @@ public class HashCodeCodec extends LeafObjectCodec { @Override - public void serialize(HashCode obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, HashCode obj, CodedOutputStream codedOut) + throws IOException { codedOut.writeByteArrayNoTag(obj.asBytes()); } @Override - public HashCode deserialize(CodedInputStream codedIn) throws IOException { + public HashCode deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws IOException { return HashCode.fromBytes(codedIn.readByteArray()); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/IntegerCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/IntegerCodec.java index 922061b1e58108..aa1fcf04590db6 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/IntegerCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/IntegerCodec.java @@ -27,12 +27,15 @@ public Class getEncodedClass() { } @Override - public void serialize(Integer value, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, Integer value, CodedOutputStream codedOut) + throws IOException { codedOut.writeInt32NoTag(value); } @Override - public Integer deserialize(CodedInputStream codedIn) throws IOException { + public Integer deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { return codedIn.readInt32(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LeafObjectCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LeafObjectCodec.java index 2d546d4d0c2146..1462d802d427f7 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LeafObjectCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LeafObjectCodec.java @@ -26,26 +26,28 @@ public abstract class LeafObjectCodec implements ObjectCodec { @Override public final void serialize(SerializationContext context, T obj, CodedOutputStream codedOut) throws SerializationException, IOException { - serialize(obj, codedOut); + serialize((SerializationDependencyProvider) context, obj, codedOut); } /** - * This has the same contract as {@link #serialize}, but never uses the {@link - * SerializationContext}. + * This has the same contract as {@link #serialize}, but may only depend on {@link + * SerializationDependencyProvider} instead of the full {@link SerializationContext}. */ - public abstract void serialize(T obj, CodedOutputStream codedOut) + public abstract void serialize( + SerializationDependencyProvider dependencies, T obj, CodedOutputStream codedOut) throws SerializationException, IOException; @Override public final T deserialize(DeserializationContext context, CodedInputStream codedIn) throws SerializationException, IOException { - return deserialize(codedIn); + return deserialize((SerializationDependencyProvider) context, codedIn); } /** - * This has the same contract as {@link #deserialize}, but never uses the {@link - * DeserializationContext}. + * This has the same contract as {@link #deserialize}, but may only depend on {@link + * SerializationDependencyProvider} instead of the full {@link DeserializationContext}. */ - public abstract T deserialize(CodedInputStream codedIn) + public abstract T deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws SerializationException, IOException; } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongArrayCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongArrayCodec.java index 1f6d5db3c8c650..2b13b95209bdb2 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongArrayCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongArrayCodec.java @@ -25,7 +25,9 @@ public Class getEncodedClass() { } @Override - public void serialize(long[] obj, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, long[] obj, CodedOutputStream codedOut) + throws IOException { codedOut.writeInt32NoTag(obj.length); for (long l : obj) { codedOut.writeInt64NoTag(l); @@ -33,7 +35,8 @@ public void serialize(long[] obj, CodedOutputStream codedOut) throws IOException } @Override - public long[] deserialize(CodedInputStream codedIn) throws IOException { + public long[] deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { long[] result = new long[codedIn.readInt32()]; for (int i = 0; i < result.length; i++) { result[i] = codedIn.readInt64(); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongCodec.java index dae90ac2002641..c6513995c6ba98 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/LongCodec.java @@ -27,12 +27,15 @@ public Class getEncodedClass() { } @Override - public void serialize(Long value, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, Long value, CodedOutputStream codedOut) + throws IOException { codedOut.writeInt64NoTag(value); } @Override - public Long deserialize(CodedInputStream codedIn) throws IOException { + public Long deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws IOException { return codedIn.readInt64(); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MessageLiteCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MessageLiteCodec.java index 119069c1952d22..ac823736e97bfc 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MessageLiteCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MessageLiteCodec.java @@ -48,12 +48,15 @@ public Class getEncodedClass() { } @Override - public void serialize(MessageLite message, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, MessageLite message, CodedOutputStream codedOut) + throws IOException { codedOut.writeMessageNoTag(message); } @Override - public MessageLite deserialize(CodedInputStream codedIn) + public MessageLite deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws IOException, SerializationException { // Don't hold on to full byte array when constructing this proto. codedIn.enableAliasing(false); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MethodCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MethodCodec.java index 37b687cc8ae1de..2955a4bcb9585d 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MethodCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/MethodCodec.java @@ -32,25 +32,27 @@ public Class getEncodedClass() { } @Override - public void serialize(Method obj, CodedOutputStream codedOut) + public void serialize( + SerializationDependencyProvider dependencies, Method obj, CodedOutputStream codedOut) throws SerializationException, IOException { - CLASS_CODEC.serialize(obj.getDeclaringClass(), codedOut); - stringCodec().serialize(obj.getName(), codedOut); + CLASS_CODEC.serialize(dependencies, obj.getDeclaringClass(), codedOut); + stringCodec().serialize(dependencies, obj.getName(), codedOut); Class[] parameterTypes = obj.getParameterTypes(); codedOut.writeInt32NoTag(parameterTypes.length); for (Class parameter : parameterTypes) { - CLASS_CODEC.serialize(parameter, codedOut); + CLASS_CODEC.serialize(dependencies, parameter, codedOut); } } @Override - public Method deserialize(CodedInputStream codedIn) throws SerializationException, IOException { - Class clazz = CLASS_CODEC.deserialize(codedIn); - String name = stringCodec().deserialize(codedIn); + public Method deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException, IOException { + Class clazz = CLASS_CODEC.deserialize(dependencies, codedIn); + String name = stringCodec().deserialize(dependencies, codedIn); Class[] parameters = new Class[codedIn.readInt32()]; for (int i = 0; i < parameters.length; i++) { - parameters[i] = CLASS_CODEC.deserialize(codedIn); + parameters[i] = CLASS_CODEC.deserialize(dependencies, codedIn); } try { return clazz.getDeclaredMethod(name, parameters); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SingletonCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SingletonCodec.java index c6e921fc30da98..b208842e986fe2 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SingletonCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/SingletonCodec.java @@ -53,12 +53,15 @@ public Class getEncodedClass() { } @Override - public void serialize(T t, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, T t, CodedOutputStream codedOut) + throws IOException { codedOut.writeByteArrayNoTag(mnemonic); } @Override - public T deserialize(CodedInputStream codedIn) throws SerializationException, IOException { + public T deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException, IOException { // Get ByteBuffer instead of raw bytes, as it may be a direct view of the data and not a copy, // which is much more efficient. ByteBuffer readMnemonic = codedIn.readByteBuffer(); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/UUIDCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/UUIDCodec.java index 545cb0190a5841..70392d7c460cd0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/UUIDCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/UUIDCodec.java @@ -27,13 +27,16 @@ public Class getEncodedClass() { } @Override - public void serialize(UUID uuid, CodedOutputStream codedOut) throws IOException { + public void serialize( + SerializationDependencyProvider dependencies, UUID uuid, CodedOutputStream codedOut) + throws IOException { codedOut.writeInt64NoTag(uuid.getMostSignificantBits()); codedOut.writeInt64NoTag(uuid.getLeastSignificantBits()); } @Override - public UUID deserialize(CodedInputStream codedIn) throws SerializationException, IOException { + public UUID deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException, IOException { return new UUID(codedIn.readInt64(), codedIn.readInt64()); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/strings/UnsafeStringCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/strings/UnsafeStringCodec.java index 4381ef60162b3c..59513c21b9bdb0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/strings/UnsafeStringCodec.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/strings/UnsafeStringCodec.java @@ -16,6 +16,7 @@ import com.google.devtools.build.lib.skyframe.serialization.LeafObjectCodec; import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec; +import com.google.devtools.build.lib.skyframe.serialization.SerializationDependencyProvider; import com.google.devtools.build.lib.skyframe.serialization.SerializationException; import com.google.devtools.build.lib.unsafe.StringUnsafe; import com.google.protobuf.CodedInputStream; @@ -58,7 +59,8 @@ public MemoizationStrategy getStrategy() { } @Override - public void serialize(String obj, CodedOutputStream codedOut) + public void serialize( + SerializationDependencyProvider dependencies, String obj, CodedOutputStream codedOut) throws SerializationException, IOException { byte coder = stringUnsafe.getCoder(obj); byte[] value = stringUnsafe.getByteArray(obj); @@ -76,7 +78,8 @@ public void serialize(String obj, CodedOutputStream codedOut) } @Override - public String deserialize(CodedInputStream codedIn) throws SerializationException, IOException { + public String deserialize(SerializationDependencyProvider dependencies, CodedInputStream codedIn) + throws SerializationException, IOException { int length = codedIn.readInt32(); byte coder; if (length >= 0) { diff --git a/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java b/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java index 95dfc0a7943109..3980c4bbeb38e8 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/PathFragment.java @@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.actions.CommandLineItem; import com.google.devtools.build.lib.skyframe.serialization.LeafObjectCodec; +import com.google.devtools.build.lib.skyframe.serialization.SerializationDependencyProvider; import com.google.devtools.build.lib.skyframe.serialization.SerializationException; import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant; import com.google.devtools.build.lib.util.FileType; @@ -842,15 +843,17 @@ public Class getEncodedClass() { } @Override - public void serialize(PathFragment obj, CodedOutputStream codedOut) + public void serialize( + SerializationDependencyProvider dependencies, PathFragment obj, CodedOutputStream codedOut) throws SerializationException, IOException { - stringCodec().serialize(obj.normalizedPath, codedOut); + stringCodec().serialize(dependencies, obj.normalizedPath, codedOut); } @Override - public PathFragment deserialize(CodedInputStream codedIn) + public PathFragment deserialize( + SerializationDependencyProvider dependencies, CodedInputStream codedIn) throws SerializationException, IOException { - return createAlreadyNormalized(stringCodec().deserialize(codedIn)); + return createAlreadyNormalized(stringCodec().deserialize(dependencies, codedIn)); } } }