Skip to content

Commit

Permalink
Breaking change: Lock down visibility for descriptor syntax APIs.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zhangskz authored and mkruskal-google committed Nov 30, 2023
1 parent 80337cb commit 1aeacd4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
8 changes: 0 additions & 8 deletions java/core/src/main/java/com/google/protobuf/Descriptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ public List<FileDescriptor> getPublicDependencies() {
}

/** The syntax of the .proto file. */
@Deprecated
public
enum Syntax {
UNKNOWN("unknown"),
PROTO2("proto2"),
Expand All @@ -156,8 +154,6 @@ enum Syntax {
}

/** Get the syntax of the .proto file. */
@Deprecated
public
Syntax getSyntax() {
if (Syntax.PROTO3.name.equals(proto.getSyntax())) {
return Syntax.PROTO3;
Expand Down Expand Up @@ -1273,8 +1269,6 @@ public OneofDescriptor getRealContainingOneof() {
* 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);
Expand Down Expand Up @@ -2843,8 +2837,6 @@ public OneofDescriptorProto toProto() {
return proto;
}

@Deprecated
public
boolean isSynthetic() {
return fields.length == 1 && fields[0].isProto3Optional;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;
Expand Down Expand Up @@ -1340,7 +1341,7 @@ private IRubyObject setFieldInternal(
// Keep track of what Oneofs are set
if (value.isNil()) {
oneofCases.remove(oneofDescriptor);
if (!oneofDescriptor.isSynthetic()) {
if (!LegacyOneofDescriptor.isSynthetic(oneofDescriptor)) {
addValue = false;
}
} else {
Expand Down

0 comments on commit 1aeacd4

Please sign in to comment.