Skip to content

pxf-runtime: ship companions for google.protobuf Any, Struct and kin - #185

Merged
trendvidia merged 1 commit into
mainfrom
pxf-android/wkt-companions-539
Nov 6, 2026
Merged

trendvidia merged 1 commit into
mainfrom
pxf-android/wkt-companions-539

Conversation

@bfrancojr

Copy link
Copy Markdown
Collaborator

Prototype for trendvidia/protowire#539, as a draft. It needs your decision there. This advances #168: it adds the lite test that #168's lite half asks for.

Problem. A lite schema with a google.protobuf.Any field (or Empty, FieldMask, Struct, Value, ListValue, NullValue) does not compile. The generated meta names com.google.protobuf.AnyPxfMeta, and nothing generates that class.

What this does

  • :pxf-runtime ships the companions for these types in org.protowire.pxf.wkt. They are protoc-gen-pxf-java-meta's output for the four google files, with only the package line changed. pxf-runtime/scripts/regen-wkt-companions.sh <spec checkout> regenerates them, and --check diffs them against fresh output.
  • The plugin change is plugin: point google.protobuf Any, Struct and kin at runtime companions protowire#550. This PR pins the plugin at that branch head (9e54740). The pin must move to spec main before merge.
  • These types are written as ordinary blocks. An Any is written as type_url and value, because the lite tier has no type resolver. The rule in protowire#501 allows that.

Evidence

  • GoogleMessagesLiteTest: 5 tests pass. They round-trip a field of each type, a repeated Any, a map of Any, nested Struct, Value and ListValue, and an Any whose bytes hold an unknown field and a repeated field.
  • At the current pin, the same module fails in compileJava with cannot find symbol in GoogleMessagesPxfMeta.java. That is #539 reproduced.
  • Cross-port check: I wrote the message's PB bytes and the lite text to files. protowire-go pxf.Marshal on the same bytes gives text byte-for-byte equal to the lite text. Go pxf.Unmarshal of the lite text gives a message proto.Equal to the original. (protowire-go at 3331d3b, through a scratch program; this check is not in CI.)
  • ./gradlew build with the plugin from the spec branch: BUILD SUCCESSFUL, 827 tests, 0 failures.

Not done in this prototype

  • No CI step runs regen-wkt-companions.sh --check, so a plugin change could leave these copies stale without failing anything.
  • A field of another google.protobuf type, such as Type or Api, still does not compile. Protowire#550 lists this.

…(protowire#539)

A lite schema with a google.protobuf.Any, Empty, FieldMask, Struct, Value
or ListValue field did not compile: the generated meta named
com.google.protobuf.AnyPxfMeta, which nothing generates. PXF reads these
types as ordinary messages, so they need ordinary companions. They now
ship in org.protowire.pxf.wkt, generated by protoc-gen-pxf-java-meta from
the four google files with only the package changed, and the plugin from
trendvidia/protowire#550 points there. Pins the plugin at that branch.

GoogleMessagesLiteTest round-trips a field of each type, an Any holding
bytes no body could reproduce among them, as #168's lite half asks.
@Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; }
@Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; }
@Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; }
@Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; }
@Override public Map<Integer, String> enumTypes() { return ENUM_TYPES; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
@Override public Set<Integer> requiredFields() { return REQUIRED_FIELDS; }
@Override public Map<Integer, String> defaults() { return DEFAULTS; }
public Set<Integer> nullableFields() { return NULLABLE_FIELDS; }
public Set<Integer> implicitPresenceFields() { return IMPLICIT_PRESENCE_FIELDS; }
@bfrancojr
bfrancojr marked this pull request as ready for review November 5, 2026 21:58
@trendvidia
trendvidia merged commit 5f8cf9a into main Nov 6, 2026
4 checks passed
@trendvidia
trendvidia deleted the pxf-android/wkt-companions-539 branch November 6, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants