Bridges a generated Scala message to protobuf-java's DynamicMessage.
The point is leverage rather than convenience. Text format, and later JSON, have long specifications full of special cases - Well-Known Type shorthands, enum naming, field ordering - and protobuf-java already implements all of it against Message. Converting once and delegating is both far less code than a second implementation and far more likely to agree with every other protobuf library.
The conversion leans entirely on GeneratedMessage.getFieldByNumber returning base values, so nothing here has to know that a field's Scala type may be a mapped one.
Goes through bytes rather than reconstructing the Scala value field by field, which keeps the inverse of toDynamic out of existence entirely: the generated parser is already the authority on how to read this message.
Unknown fields do not survive the round trip. toProtoString prints them as 9999: 42, but text format records no type for them, so there is nothing to parse them back into; the default parser rejects the input outright ("Input contains unknown fields and/or extensions") and this one skips them. Use the binary encoding when unknown fields have to be preserved - it is the only one that can.
Built partially on purpose: a message with an unset required field (proto2, or editions' LEGACY_REQUIRED) is representable in Scala, and refusing to print it would make debugging that exact situation impossible.