Repository navigation
Conversation
RuntimeMessageAdapter wrote proto3 implicit-presence fields that hold their identity value. Generated adapters and protoc skip them. Encode and encodedSize now use the identity check that JSON already uses. Java compact output now gives the same bytes as generated code.
oldergod
marked this pull request as ready for review
November 5, 2026 12:37
Schema adapters label proto3 wrapper fields OMIT_IDENTITY, and wrapper adapters expose a scalar identity. The identity skip dropped present wrappers that hold 0, false, or an empty string. Generated code writes these wrappers, so the skip now ignores message fields.
oldergod
marked this pull request as draft
November 5, 2026 12:37
oldergod
marked this pull request as ready for review
November 5, 2026 13:47
The schema enum adapter had no identity, so a proto3 enum field set to its zero constant was written. Like generated enum adapters, the schema enum adapter now uses the constant with tag 0 as identity. The schema binding also treats the tag 0 as the identity, because schema enum values can be names or tags.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RuntimeMessageAdapterwrote proto3 implicit-presence fields that hold their identity value, such as0,"", empty bytes, or the zero enum constant.Generated adapters and protoc skip these fields.
Java
compact = truecode, direct reflective adapters, andSchema.protoAdapter()use this path.encode(withProtoWriterandReverseProtoWriter) andencodedSizenow skip identity values for scalar and enum fields with theOMIT_IDENTITYlabel.proto2 fields, proto3
optionalfields, oneof members, and message fields keep their current behavior.A present wrapper that holds an identity value is still written, as in generated code.
JSON output does not change.
The schema enum adapter had no identity, so
Schema.protoAdapter()still wrote a zero enum.Like generated enum adapters, it now uses the constant with tag 0 as identity.
Schema enum values can be constant names or tags, so the schema binding skips both the zero constant name and
0.Release note: Java
compact = truecode,ProtoAdapter.newMessageAdapter, andSchema.protoAdapternow give different bytes for proto3 messages.They no longer write implicit-presence fields that hold an identity value, so their bytes now match protoc and generated adapters.
The
identityof a schema enum adapter is now the name of its constant with tag 0, or null if there is none.