Skip to content

Ship R8 and ProGuard rules in wire-runtime - #3835

Open
oldergod wants to merge 1 commit into
masterfrom
bquenaudon.2026-12-01.r8-consumer-rules
Open

oldergod wants to merge 1 commit into
masterfrom
bquenaudon.2026-12-01.r8-consumer-rules

Conversation

@oldergod

@oldergod oldergod commented Dec 1, 2026

Copy link
Copy Markdown
Member

The wire-runtime jar now contains R8 and ProGuard rules at META-INF/proguard/wire-runtime.pro.
Apps that shrink their code no longer need to write rules for what the runtime finds by name or by class identity:

  • The ADAPTER field of each message, which ProtoAdapter.get(Class) reads.
  • The fromValue(int) method of each enum, which RuntimeEnumAdapter calls.
  • The names of ProtoAdapter and its built-in adapters, which WireField and WireOneofField name in strings such as com.squareup.wire.ProtoAdapter#STRING.
  • The annotations that the reflective adapters read: WireField, WireOneofField, WireSealedOneof, WireBoxedOneof and WireEnumConstant.
    In R8 full mode, nothing implements them, so R8 can replace their methods with code that throws.
  • OneOf. Nothing creates one, so R8 can make it an empty class and merge the base class of a sealed oneof into it.
    The sealed oneof field then has the type OneOf, and the reflective adapter throws NoSuchFieldException for its <NAME>_KEYS.
    Cash App found this in its R8 builds.
  • Classes with WireEnclosingType, as that annotation's documentation asks.

The Wire JSON docs now say that apps must keep the messages that they convert to JSON.
Wire cannot know which messages these are.

The runtime finds the ADAPTER field, fromValue(int), the built-in adapters, its own annotations
and OneOf by name or by class identity. Apps that shrink their code had to write these rules
themselves. The rules are now in the wire-runtime jar, and R8 and ProGuard read them from there.

This branch has not been deployed

No deployments
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.

1 participant