-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Java compile version issue when upgrading to 3.12.4 #7827
Comments
I'm able to reproduce the issue in a simple Maven project https://github.com/suztomo/protobuf-i7827. I found a similar issue which says "-source 8 -target 8" generates wrong bytecode and ''--release 8" fixes this. |
It sounds like the linkage checker may soon help detect this, but FYI, another option is to run Animal Sniffer, as we do in Guava. I've heard mixed things about the If you want to avoid this particular error without changing compiler settings, you may be able to change the code to upcast the buffer to [edit: a post with some explanation] |
Uh-oh:
(I assume you're building releases with Maven, but I see some (Bazel) BUILD files, too, so it's possible that I'm wrong about that.) |
Oh, and I had trouble building anything with Maven with JDK11+ because of a maven-surefire-plugin problem with [edit: The problem is https://issues.apache.org/jira/browse/SUREFIRE-1439, and it's apparently fixable by upgrading to maven-surefire-plugin 2.21.0. I have sent #7830 to update to the newest version, 3.0.0-M5, but it's stuck because CI uses an old version of Maven.] It's possible that <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<phase />
</execution>
</executions>
</plugin> |
This avoids https://issues.apache.org/jira/browse/SUREFIRE-1439, which I hit while investigating protocolbuffers#7827
It sounds like the right solution here is to pass The pom.xml suggests that you're actually targeting Java 7, not 8, so that would be The downside to that is that you need to require that developers who build protobuf themselves build with JDK 9+ to use |
Ah, but I then tried:
But:
(nor with target 1.8, so (a) you can't just bump to that (even if you wanted to) and (b) this doesn't help us for Guava, either) The only truly correct solution may be to build with Java 7 [edit: but I don't know how well supported that is nowadays, including through Maven] (or at least with Java 8 pointed at a Java 7 bootclasspath). Animal Sniffer can help somewhat, but the fact that it doesn't actually fail the build is unfortunate. Maybe the best bet is a combination of (a) requiring building with Java 8 and (b) asking Animal Sniffer to look for compatibility with Java 7? |
Err, I may have actually seen some evidence that Animal Sniffer's signatures for Java 7 likewise reject usage of So, if you want to use Animal Sniffer, you'll probably have to mark your Supposedly you can generate your own signatures for the JDK or anything else, but that sounds like a pain. |
FYI, in Guava, we are adding the upcasts (indirectly, by introducing helper methods): google/guava#3994 Hopefully we will do more to actually detect such problems. Fortunately, as I note in internal issue 156345036, it seems likely that the
We're hoping to not require building with JDK 8:
|
Would dropping support for java7 and using |
It would, but |
I saw you mentioned cast to |
Yes, upcasting to |
Here's an attempt to identify affected calls (excluding tests): covariants.txt That's 60 calls -- more than I'd remembered. |
Just replace all of them seems feasible
…On Wed, Aug 26, 2020 at 7:20 AM Chris Povirk ***@***.***> wrote:
Here's an attempt to identify affected calls (excluding tests):
covariants.txt
<https://github.com/protocolbuffers/protobuf/files/5130396/covariants.txt>
That's 60 calls -- more than I'd remembered.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7827 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHUPZLARRHU2XXZJC3HFLLSCUK3XANCNFSM4QDS7ORA>
.
|
BTW, internally we are using java8, why this didn't fail internally? |
Internally, we build against a Java 8 bootclasspath. It's a lot like building with |
How does |
It produces a javac build error, so it's a problem even without Animal Sniffer. I have wondered if we could find a workaround (like putting Unsafe on the classpath), but I haven't experimented. |
Can you point out to me where are those |
You can set
|
What's the build and release process for this library? Is it being built on an individual developer workstation with |
I think it’s kokoro + docker
…On Wed, Aug 26, 2020 at 12:51 PM Elliotte Rusty Harold < ***@***.***> wrote:
What's the build and release process for this library? Is it being built
on an individual developer workstation with mvn perform:release or
equivalent? If so, we might want to switch to kokoro+Rapid for multiple
reasons.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7827 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHUPZMSKIKIQ4UICQJQMJ3SCVRUNANCNFSM4QDS7ORA>
.
|
Sent a fix internally for our release process. Seems we are using the default |
@elharo: I just CCed you. (If it's not showing up, search for the URL of this issue.) Good point about the search. A search like |
@TeBoring Hi Paul, do you have plan to release a fix to this issue? |
I came to report that I ran into a similar issue. Different method from op but one that's listed in convariants.txt so I guess you're aware of it:
In general, does this prevent people/companies from using protobuf 3.12.4+ if they are on JDK < 10? If I understand correctly, these would sometimes show up as a runtime error, like in this case you could be calling a method on Apache Beam. If so it might be helpful if this issue was hi-lighted better the release note as a known issue. |
Not necessarily. It just means that the Protobuf Java developers have to arrange for the
|
I understand that at some point in the future this may be fixed. What I'm saying is that today, if any of the Java/Scala etc libraries pulled in 3.12.4+ (because why not?) it could result to a runtime error in a production system. Thankfully my work code had a decent code coverage, so we caught this, but not everyone might. So I'm asking this issue be highlighted in the release note of 3.12.4, 3.13.0, and 3.13.0.1 as a known regression with regard to JDK 8. |
Beam's protobuf dependency hit this. |
Is this fixed in 3.14.0 ? |
I see it's fixed in 3.14.0. Thank you. |
Fyi, we use |
Thanks. It looks like the difference is that you never refer directly to the type |
Oh, I see. Method handles are available since Java 7, but Android is a bit of a problem. |
Issue #2265 described a bug which broke the plugin due to an already fixed protobuf issue protocolbuffers/protobuf#7827 the issue author created a fork in https://github.com/hedronvision/bazelbuild-intellij. PiperOrigin-RevId: 363130962
Issue #2265 described a bug which broke the plugin due to an already fixed protobuf issue protocolbuffers/protobuf#7827 the issue author created a fork in https://github.com/hedronvision/bazelbuild-intellij. PiperOrigin-RevId: 363130962
Issue #2265 described a bug which broke the plugin due to an already fixed protobuf issue protocolbuffers/protobuf#7827 the issue author created a fork in https://github.com/hedronvision/bazelbuild-intellij. PiperOrigin-RevId: 363188004
This avoids https://issues.apache.org/jira/browse/SUREFIRE-1439, which I hit while investigating #7827
What version of protobuf and what language are you using?
Version: protobuf-java 3.12.4
Language: Java
What did you do?
Steps to reproduce the behavior:
When executing this line of code (https://github.com/googleapis/java-bigtable-hbase/blob/master/bigtable-client-core-parent/bigtable-client-core/src/test/java/com/google/cloud/bigtable/grpc/scanner/ReadRowsAcceptanceTest.java#L184), we are seeing this error message:
This started when upgrading from protobuf-java 3.12.2 to 3.12.4. I can confirm that testing locally, the test fails with a Java 8 build and passes with Java 11 (
CharBuffer.flip()
changed between those two versions of java). Were there any changes to the language compile level in protobuf-java recently that would explain this?Thanks for your help!
The text was updated successfully, but these errors were encountered: