Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gRPC Java compiler isn't using fully qualified names for String #10316

Closed
pkwarren opened this issue Jun 27, 2023 · 2 comments · Fixed by #10321
Closed

gRPC Java compiler isn't using fully qualified names for String #10316

pkwarren opened this issue Jun 27, 2023 · 2 comments · Fixed by #10321
Milestone

Comments

@pkwarren
Copy link
Contributor

What version of gRPC-Java are you using?

v1.56.0

What is your environment?

Linux, Java 17

What did you expect to see?

Generated code from the gRPC Java compiler should use fully qualified names for String.

What did you see instead?

Compilation error for inputs that include a message type named String.

Steps to reproduce the bug

syntax = "proto3";

package example;

message String {
  string val = 1;
}

message GetThingRequest {
  string id = 1;
}

message GetThingResponse {
  String id = 1;
}

service ExampleService {
  rpc GetThing(GetThingRequest) returns (GetThingResponse);
}

To generate code, I'm using buf with this buf.gen.yaml:

version: v1
managed:
  enabled: true
plugins:
- plugin: buf.build/protocolbuffers/java
  out: gen
- plugin: buf.build/grpc/java
  out: gen

The issue seems to be that the variable here

vars["String"] = "java.lang.String";
isn't being used at the following locations:

I'm happy to raise a PR to fix but I'm having a hard time getting the local build to work end to end on MacOS arm64 and Linux arm64. I imagine this will require not only changing the compiler but also potentially updating tests and regenerating code with the new compiler.

@pkwarren
Copy link
Contributor Author

Opened related issue #10317 for updating the compilation docs to work with newer protoc versions.

@ejona86
Copy link
Member

ejona86 commented Jun 27, 2023

Yeah, we need to use the fully-qualified String. I know it is annoying for us Java developers to need to build C++, but let's see if that gets working in #10317.

larry-safran pushed a commit that referenced this issue Jun 29, 2023
Currently, the gRPC compiler isn't properly using the fully qualified
string name `java.lang.String` instead of `String`. Update the generator
to use the `$String$` alias to avoid compile issues with protobuf
messages called String.

Fixes #10316.
@ejona86 ejona86 added this to the 1.57 milestone Jun 29, 2023
temawi pushed a commit to temawi/grpc-java that referenced this issue Jun 29, 2023
Currently, the gRPC compiler isn't properly using the fully qualified
string name `java.lang.String` instead of `String`. Update the generator
to use the `$String$` alias to avoid compile issues with protobuf
messages called String.

Fixes grpc#10316.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants