From 384c6e6544bd471e6a31161edd64a8d69dcf5bad Mon Sep 17 00:00:00 2001 From: Jeff Schnitzer Date: Tue, 4 Oct 2022 12:46:15 -0700 Subject: [PATCH 1/2] Add serialVersionUID to ByteString and subclasses --- java/core/src/main/java/com/google/protobuf/ByteString.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/core/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java index 0e03ebd14ee5..a0905c42bc6d 100644 --- a/java/core/src/main/java/com/google/protobuf/ByteString.java +++ b/java/core/src/main/java/com/google/protobuf/ByteString.java @@ -75,6 +75,7 @@ */ @CheckReturnValue public abstract class ByteString implements Iterable, Serializable { + private static final long serialVersionUID = 1L; /** * When two strings to be concatenated have a combined length shorter than this, we just copy @@ -945,6 +946,8 @@ public final String toStringUtf8() { /** Base class for leaf {@link ByteString}s (i.e. non-ropes). */ abstract static class LeafByteString extends ByteString { + private static final long serialVersionUID = 1L; + @Override protected final int getTreeDepth() { return 0; @@ -1603,6 +1606,7 @@ protected int getOffsetIntoBytes() { // Keep this class private to avoid deadlocks in classloading across threads as ByteString's // static initializer loads LiteralByteString and another thread loads BoundedByteString. private static final class BoundedByteString extends LiteralByteString { + private static final long serialVersionUID = 1L; private final int bytesOffset; private final int bytesLength; From 23537c8809a14439cdc64e556e72b509b7a3998f Mon Sep 17 00:00:00 2001 From: Jeff Schnitzer Date: Mon, 10 Oct 2022 22:10:18 -0700 Subject: [PATCH 2/2] Remove duplicate serialVersionUID --- java/core/src/main/java/com/google/protobuf/ByteString.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java index a0905c42bc6d..1acbad08b4a3 100644 --- a/java/core/src/main/java/com/google/protobuf/ByteString.java +++ b/java/core/src/main/java/com/google/protobuf/ByteString.java @@ -1606,8 +1606,6 @@ protected int getOffsetIntoBytes() { // Keep this class private to avoid deadlocks in classloading across threads as ByteString's // static initializer loads LiteralByteString and another thread loads BoundedByteString. private static final class BoundedByteString extends LiteralByteString { - private static final long serialVersionUID = 1L; - private final int bytesOffset; private final int bytesLength;