Protobuf: v3.8.0 Produces Java Code that does not compile

Created on 20 Jun 2019  路  6Comments  路  Source: protocolbuffers/protobuf

What version of protobuf and what language are you using?
Version: v3.8.0
Language: Java

What operating system (Linux, Windows, ...) and version?
macOS 10.14.5

What runtime / compiler are you using (e.g., python version or gcc version)
I'm using the compiler published as an artifact in a Maven repo.

What did you do?
v3.7.1 works fine. When I update to v3.8.0, I see the following issue.

Using the following gradle script snippet:

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.8.0'
    }
    //noinspection GroovyAssignabilityCheck
    plugins {
        grpc {
            artifact = "io.grpc:protoc-gen-grpc-java:1.21.0"
        }
    }
    generateProtoTasks {
        ofSourceSet("main")*.plugins {
            grpc {}
        }
    }
    generatedFilesBaseDir = "$projectDir/src-generated"
}

Run the generateProto task.

What did you expect to see
The generated code should compile.

What did you see instead?
The generated classes that the plugin and protoc generate do not compile. The UnusedPrivateParameter class (without a package) is missing. Here's an snippet from some of the generated source:

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(
      UnusedPrivateParameter unused) {
    return new MyType();
  }

Compile Error:

error: cannot find symbol
      UnusedPrivateParameter unused) {
      ^
  symbol:   class UnusedPrivateParameter
  location: class MyType

Most helpful comment

Can you upgrade your protobuf runtime library too? https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java/3.8.0

All 6 comments

Can you upgrade your protobuf runtime library too? https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java/3.8.0

@pluttrell were you able to fix the issue? I am also having same issue.

I had the same problem, and adding the dependency as suggested resolved the issue for me.

@hilbertglm thanks for the reply. It worked now for me too.

Yes, that did resolve my issue. Sorry for the delay.

Thanks

Can you upgrade your protobuf runtime library too? https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java/3.8.0

Thanks it did resolve the issue

Was this page helpful?
0 / 5 - 0 ratings