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
pull/14892/head
Sandy Zhang 1 year ago committed by Mike Kruskal
parent 80337cb884
commit 1aeacd4f4e
  1. 8
      java/core/src/main/java/com/google/protobuf/Descriptors.java
  2. 3
      ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.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;
}

@ -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 {

Loading…
Cancel
Save