Protoc won't generate java classes for nested classes having the same name

Skip to first unread message

Alexander Glukhov

Jan 20, 2023, 3:19:13 AMJan 20
to Protocol Buffers
Hello, I faced with an error when working with protoc for Java.

The issue was described on, but the issue was closed a few months ago.
I've provided some information about reproduction as well as some possible workarounds for this error in the original issue.

This problem can easily be solved by using a copy of original proto file, but this requires maintaining several identical proto files with the same structure
but with the different message names.

Personally, the only backward compatible solution I can see is to add an option that allows you to merge class names for nested classes with the name of outer class.  

For example, if the outer class has name `Payload`, and the nested class has name `Payload`, that flag will generate multiple java classes: `Payload` and `Payload.PayloadPayload`,
instead of `Payload` and `Payload.Payload`.

I think I can try to implement this feature.


Jerry Berg

Jan 27, 2023, 12:20:19 PMJan 27
to Protocol Buffers
Hi Alexander, can you provide a link to the motivating gRPC contract example?

Reply all
Reply to author
0 new messages