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

emptyLongList() missing when generating repeated primatives in proto3 java #5806

Closed
KDawgOne opened this issue Mar 2, 2019 · 2 comments
Closed

Comments

@KDawgOne
Copy link

KDawgOne commented Mar 2, 2019

The following .proto file creates Java code that cannot be compiled with javac (Using protobuf 3.6.1) and Java 1.8.0_144. The problem seams to apply to any primitive except for string.

syntax = "proto3";

option java_package = "com.protobuf.test";
option java_outer_classname = "ProtoTest";

message IAmBroken
{
repeated int64 whatHappened = 1;
}

The following (redacted) output is generated when it is compiled with javac

[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:47: error: cannot find symbol
[javac]       whatHappened_ = emptyLongList();
[javac]                       ^
[javac]   symbol:   method emptyLongList()
[javac]   location: class IAmBroken
[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:76: error: cannot find symbol
[javac]                 whatHappened_ = newLongList();
[javac]                                 ^
[javac]   symbol:   method newLongList()
[javac]   location: class IAmBroken
[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:86: error: cannot find symbol
[javac]                 whatHappened_ = newLongList();
[javac]                                 ^
[javac]   symbol:   method newLongList()
[javac]   location: class IAmBroken
[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:363: error: cannot find symbol
[javac]         whatHappened_ = emptyLongList();
[javac]                         ^
[javac]   symbol:   method emptyLongList()
[javac]   location: class Builder
[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:485: error: cannot find symbol
[javac]       private com.google.protobuf.Internal.LongList whatHappened_ = emptyLongList();
[javac]                                                                     ^
[javac]   symbol:   method emptyLongList()
[javac]   location: class Builder
[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:488: error: cannot find symbol
[javac]           whatHappened_ = mutableCopy(whatHappened_);
[javac]                           ^
[javac]   symbol:   method mutableCopy(LongList)
[javac]   location: class Builder
[javac] C:\codetest\src\main\java\com\protobuf\test\ProtoTest.java:546: error: cannot find symbol
[javac]         whatHappened_ = emptyLongList();
[javac]                         ^
[javac]   symbol:   method emptyLongList()
[javac]   location: class Builder
@clehene
Copy link

clehene commented Mar 4, 2019

This is not a bug. You're likely mixing protoc 3.7.x with a 3.6.x protobuf-java dependency.
The empty[X]List is part of GeneratedMessageV3 since 3.7.x.
The 3.7.0 version was not yet released in maven central, however you can use protobuf-java 3.7.0-rc1 and it should work.

@KDawgOne
Copy link
Author

KDawgOne commented Mar 4, 2019

OK, looks like this issue no longer exists in 3.7.0-rc1 and the code compiled without any errors.

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants