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

52 views
Skip to first unread message

Alexander Glukhov

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

The issue was described on https://github.com/protocolbuffers/protobuf/issues/6987, 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.

Regards,
Alexander.

Jerry Berg

unread,
Jan 27, 2023, 12:20:19 PM1/27/23
to Protocol Buffers
Hi Alexander, can you provide a link to the motivating gRPC contract example?
Thanks,
Jerry

Reply all
Reply to author
Forward
0 new messages