diff --git a/java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java b/java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java index a370870c89..b503e55dbe 100644 --- a/java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java +++ b/java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java @@ -167,7 +167,7 @@ final class DescriptorMessageInfoFactory implements MessageInfoFactory { } }; } - if (fd.getContainingOneof() != null && !fd.getContainingOneof().isSynthetic()) { + if (fd.getRealContainingOneof() != null) { // Build a oneof member field for non-synthetic oneofs. builder.withField(buildOneofMember(messageType, fd, oneofState, enforceUtf8, enumVerifier)); continue; diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java index 91f7225755..cbad3ca01f 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java @@ -2460,8 +2460,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri final Class> builderClass, final String containingOneofCamelCaseName) { isOneofField = - descriptor.getContainingOneof() != null - && !descriptor.getContainingOneof().isSynthetic(); + descriptor.getRealContainingOneof() != null; hasHasMethod = descriptor.hasPresence(); ReflectionInvoker reflectionInvoker = new ReflectionInvoker(