From 1aeacd4f4eb4e0aa05d6336e2988a565e475e9a0 Mon Sep 17 00:00:00 2001 From: Sandy Zhang Date: Wed, 29 Nov 2023 19:32:22 -0800 Subject: [PATCH] Breaking change: Lock down visibility for descriptor syntax APIs. Users should migrate to corresponding feature accessors (e.g. FieldDescriptor.hasPresence, EnumDescriptor.isClosed) instead of deriving these based on syntax, which will break after under Editions (https://protobuf.dev/editions/overview/) PiperOrigin-RevId: 586518687 --- .../src/main/java/com/google/protobuf/Descriptors.java | 8 -------- .../main/java/com/google/protobuf/jruby/RubyMessage.java | 3 ++- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index 330cbf3592..a8ed0e8d91 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -140,8 +140,6 @@ public final class Descriptors { } /** The syntax of the .proto file. */ - @Deprecated - public enum Syntax { UNKNOWN("unknown"), PROTO2("proto2"), @@ -156,8 +154,6 @@ public final class Descriptors { } /** Get the syntax of the .proto file. */ - @Deprecated - public Syntax getSyntax() { if (Syntax.PROTO3.name.equals(proto.getSyntax())) { return Syntax.PROTO3; @@ -1273,8 +1269,6 @@ public final class Descriptors { * Returns true if this field was syntactically written with "optional" in the .proto file. * Excludes singular proto3 fields that do not have a label. */ - @Deprecated - public boolean hasOptionalKeyword() { return isProto3Optional || (file.getSyntax() == Syntax.PROTO2 && isOptional() && getContainingOneof() == null); @@ -2843,8 +2837,6 @@ public final class Descriptors { return proto; } - @Deprecated - public boolean isSynthetic() { return fields.length == 1 && fields[0].isProto3Optional; } diff --git a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java index 12e609191d..ec57a4bff2 100644 --- a/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java +++ b/ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java @@ -42,6 +42,7 @@ import com.google.protobuf.Descriptors.OneofDescriptor; import com.google.protobuf.DynamicMessage; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.LegacyDescriptorsUtil.LegacyFileDescriptor; +import com.google.protobuf.LegacyDescriptorsUtil.LegacyOneofDescriptor; import com.google.protobuf.Message; import com.google.protobuf.UnknownFieldSet; import com.google.protobuf.util.JsonFormat; @@ -1340,7 +1341,7 @@ public class RubyMessage extends RubyObject { // Keep track of what Oneofs are set if (value.isNil()) { oneofCases.remove(oneofDescriptor); - if (!oneofDescriptor.isSynthetic()) { + if (!LegacyOneofDescriptor.isSynthetic(oneofDescriptor)) { addValue = false; } } else {