-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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_proto_library
results in spurious warning message
#8772
Comments
This was also reported in Gerrit issue tracker. |
It can be easily reproduced, e.g. in rules_closure repository:
So the problem part seems to be this one:
I have sent this PR, but apparently this doesn't help, as even with custom built Bazel version with this PR included, I still see this warning. |
Closes bazelbuild#8772. Change-Id: Ia3467b2a33ee4bfbd10cfe3f1027e292d3a967b7
@davido Your change also requires a java_tools release. |
@iirina Thanks for pointing this out. I had a strong impression, that what I was doing didn't have any effect. Could you point me to some documentation, how could I conduct I was also trying to bump Java language level to Java 8 in protobuf project: [1]. |
Of course, you can check out Manually trying out java_tools before the release. Please let me know if you have further questions or any feedback on trying out java_tools. |
Closed by mistake :) |
Thanks @iirina ! It works now. There are two completely different issues:
I applied my PR a on Bazel@HEAD, and created the zip on Linux:
then I activated in gerrit tree the custom toolchain: http_archive(
name = "local_java_tools",
urls = ["file:///home/davido/projects/bazel/bazel-bin/src/java_tools_java11.zip"]
) and build gerrit with:
Then I was still seeing two warnings (instead of dozen). The reason for that is that
Patch Gerrit to use the above diff --git a/WORKSPACE b/WORKSPACE
index 4aeef5c652..c51bea2efd 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -32,9 +32,9 @@ http_archive(
http_archive(
name = "io_bazel_rules_closure",
- sha256 = "39b7bec43e6178d065875987b18623d476acd54f355d7711ce9dce4a3eec0795",
- strip_prefix = "rules_closure-0.25",
- urls = ["https://github.com/davido/rules_closure/archive/v0.25.tar.gz"],
+ sha256 = "03140a50a6dccc3f5f000f7f9c60ae2a4c44c4f97f5f5cd76ce4506ac60b8d8f",
+ strip_prefix = "rules_closure-0.30",
+ urls = ["https://github.com/davido/rules_closure/archive/v0.30.tar.gz"],
)
# File is specific to Polymer and copied from the Closure Github -- should be
@@ -69,6 +69,11 @@ closure_repositories(
omit_rules_cc = True,
) Now I can build gerrit without those annoying warnings:
Cool, what? |
Closes bazelbuild#8772. Java compiler -target 7 (and lower) and -parameters options are mutually exclusive. Starting from version 11 the javac is issuing this warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. and is spamming the build log. This is particularly annoying, because the major project in distributed Java ecosystem Google Protobuf is targeting java language level 7, so that this spam affects everyone in the wild. But the scope of the problem is unrelated to Protobuf and every attempt to pass -target 7 javac option to the java_library rule ends up in the above spam. To rectify extend ReleaseOptionNormalizer and filter out -parameters option from the command line if java language leve is 7 or lower. Test Plan: * Build new java_tools with: $ bazel build //src:java_tools_java11.zip * Switch to using custom version of java_tools, e.g.: http_archive( name = "local_java_tools", urls = ["file:///tmp/java_tools_java11.zip"], ) * Build java source with custom java tools toolchain: cat A.java: class A {} cat BUILD: java_library( name = "a", srcs = ["A.java"], javacopts = [ "-source 7", "-target 7", ], ) $ bazel build \ --host_java_toolchain=@local_java_tools//:toolchain \ --java_toolchain=@local_java_tools//:toolchain \ :a and confirm that there is no build warning. * Retry the build without custom java tools and confirm that the warning is reported: $ bazel build :a warning: -parameters is not supported for target value 1.7. Use 1.8 or later. Change-Id: Ibec6dd14d8d4a395a6de3128cd15ccec52752d4b
Closes bazelbuild#8772. Java compiler -target 7 (and lower) and -parameters options are mutually exclusive. Starting from version 11 the javac is issuing this warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. and is spamming the build log. This is particularly annoying, because the major project in distributed Java ecosystem Google Protobuf is targeting java language level 7, so that this spam affects everyone in the wild. But the scope of the problem is unrelated to Protobuf and every attempt to pass -target 7 javac option to the java_library rule ends up in the above spam. To rectify extend ReleaseOptionNormalizer and filter out -parameters option from the command line if java language level is 7 or lower. Test Plan: * Build new java_tools with: $ bazel build //src:java_tools_java11.zip * Switch to using custom version of java_tools, e.g.: http_archive( name = "local_java_tools", urls = ["file:///tmp/java_tools_java11.zip"], ) * Build java library with custom java tools toolchain: $ cat A.java: class A {} $ cat BUILD: java_library( name = "a", srcs = ["A.java"], javacopts = [ "-source 7", "-target 7", ], ) $ bazel build \ --host_java_toolchain=@local_java_tools//:toolchain \ --java_toolchain=@local_java_tools//:toolchain \ :a and confirm that there is no build warnings. * Retry the build without custom java tools and confirm that the warning is reported: $ bazel build :a warning: -parameters is not supported for target value 1.7. Use 1.8 or later. Change-Id: Ibec6dd14d8d4a395a6de3128cd15ccec52752d4b
OK, now that I have reproduced the problem it is clear what is going on. As pointed out by @lberki the two Javac options could be mutually exclusive:
This was always like that, but JDK 11 and later were changed to be more strict about the incompatibility of the aforementioned options and perform the check and issue the warning. So that while all is fine on JDK 8:
we get this warning on JDK 11:
BTW the same holds true for JDK 13:
and upcoming JDK 14:
Moreover, now, that we fully understand the problem, it is clear that it is entirely unrelated to Why we are seeing this spam only on Reproducer: A.java: class A {} WORKSPACE: name("foo") BUILD: java_library(
name = "a",
srcs = ["A.java"],
javacopts = [
"-source 7",
"-target 7",
],
) With Bazel@HEAD I am getting:
Note, that if I change the language level to 6, I still get the same:
The spam problem is the regression of the upgrade of the remote JDK to JDK 11. Given that Protobuf rules are targeting language level 7 and given that so many projects depend in Protobuf, and considering the fact, that my attempt to drop Java 7 compatibility in Protobuf project was rejected, this regression affects almost everyone in the wild. For example in gerrit build toolchain, we are seeing this warning dozen times:
Here is the proper fix. |
Why does this problem need to be solved in Bazel, e.g. by normalizing javacopts? |
I don't see how this can be avoided by build configuration. Java toolchain definition in Bazel is unconditionally adding So that the downstream projects not putting the incompatible options, but Bazel does it. In protobuf project, this rule is used (see https://github.com/protocolbuffers/protobuf/blob/master/BUILD#L658-L659)
to produce byte code major version 51. Behind Protobuf's project back, Bazel is unconditionally adding In Gerrit project,
How should Protobuf and Gerrit (and many other) projects configure their |
#9450 would have addressed that part, right? |
Correct, however, even with #9450 merged and released, this simple java_library(
name = "a",
srcs = ["A.java"],
javacopts = [
"-source 7",
"-target 7",
,
) And that's exactly the problem of Protobuf project (and my attempt to change that was rejected upstream, see protocolbuffers/protobuf#6711). Just to make it clear: Gerrit Code Review project does not target Java 7, and as build tool chain maintainer here I totally don't care about Protobuf compatibility with Android or whatever other parties. What I do care about is that build result in Gerrit is spammed (dozen or even hundred of times?) and that the developers are complaining and that this regression with Remote JDK 11 upgrade is not fixed for months. |
I see bazel's job here as to collect javac options from multiple sources (e.g. command line Changing the configuration for the build to avoid passing combinations of flags javac warns about seems like a better solution than trying to do more javac flag parsing in bazel. I guess you could define a |
Interesting suggestion. However, even if this request would be filed to JDK project, accepted, implemented and released this would take years to be available in the wild. At that point nobody would care about Based on your suggestion, what if we would add "virtual" support for That way we would add this addition to the protobuf project to silent that annoying warning:
Alternative approach would be to patch Protobuf during the fetch and just remove the |
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
Done in: [1], that is going probably to be rejected. |
It's not too late for JDK 14, which is only 6 months out. I'm not sure it should be a priority for Bazel to work around perceived toolchain bugs; fixing them upstream seems strictly better. If you want to avoid patching dependencies, I think the other approach I mentioned of removing |
I think @davido's proposed PR is reasonable in this case. It doesn't do any harm, it's simple and was handed over to us :) I agree the Bazel team shouldn't invest much time around tuning the toolchain for very specific use-cases, but at the same time we'd like to make the life of Bazel users as easy as possible. One could use |
It regresses support for using The entire |
How can you use Have you patched your JDK to also produce parameter names even with Java 7 language level or have you patched your JDK to ignore In both cases, you could upstream your JDK patches, right? So that the open source community would benefit from it as well? |
It doesn't even require patching javac, just using a version that predates JDK-8190452. |
FWIW, Bazel project is heavily affected by the problem as well. To verify my CL at Bazel@HEAD, I am building
So, the whole Bazel Team (50 devs?) around the globe are going to see that spam dozen or hundred times a day for years to come, given that my both approaches to fix it in Protobuf repository and in Bazel repository were rejected? REALLY? |
I wasn't aware we're relying on it internally. This changes the story a bit :) At this point I see two options:
|
This wouldn't solve the problem for |
We can add a new
and use it the same way they use The second part of the problem affects
Between 1. and 2. has to be an incompatible flag somewhere for java 7 users to migrate to the new jdk7 vanilla toolchain. Right now we can go ahead with the first part of the plan ( cc @hlopko |
Isn't this is very similar to what my PR was trying to achieve and was already rejected? What makes your think that yet another attempt to do the same: drop support to target Java level 7 in Protobuf project would be accepted? With my and your suggestions, building:
in protobuf project wouldn't produce Java language Level 7 (byte code major version 51) any more.
It was me who introduced jdk9 config setting in Protobuf (to build Gerrit against newer JDK version), and it was a oversight from my side, to omit "-source 7 and target 7" options for JDK9. So in fact it is broken now in Protobuf: with JDK9 that doesn't exist any more, Java language level 8 would be generated (byte code major version 52), but with default remote JDK (JDK 11) Java language level 7 (byte code major version 51) would be generated. Suggestion: instead of adding new config sections for
I don't think these backwards compatibility efforts are really needed. |
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
FTR: This is fixed now in gerrit project.
|
For workaround bazelbuild/bazel#8772 with Bazel >= 0.29.1 TensorFlow still targets Java 1.7 (See JAVACOPTS), which doesn't support "-parameters" flag. Starting from Java 11 (default since Bazel 0.29.1), a warning message will be thrown if "-parameters" is passed. If "-Werror" also exists, the compiling action will fail. To workaround this, we override the misc value of the default java toolchain to remove "-parameters" flag. PiperOrigin-RevId: 275265568 Change-Id: I8899fa0bebe70a87fc0c6925bd8c3c6bab395761
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
This is a workaround to suppress this annoying warning: warning: -parameters is not supported for target value 1.7. Use 1.8 or later. wenn building protobuf_java. The full story can be seen in this Bazel issue: [1]. I tried hard to avoid the need for patching Protobuf on fetch, by trying to remove Java 7 compatibility mode upstream, that was rejected: [2]. Moreover, I tried hard and spent quite some time to fix the problem in Bazel: [3], in non-invasive way, but this PR was as well rejected. The next natural approach is to just patch the Protobuf source during the fetch operation. Needless to say, that the patching during the fetch has its own disavdantages, that the patch would probably need to be updated on every Protobuf upgrade. But what can you do? The developers are complaining and filling the issues in every issue tracker, as here in Gerrit Code Review project: [4]. [1] bazelbuild/bazel#8772 [3] bazelbuild/bazel#9494 [3] protocolbuffers/protobuf#6711 [4] https://bugs.chromium.org/p/gerrit/issues/detail?id=11102
For workaround bazelbuild/bazel#8772 with Bazel >= 0.29.1 TensorFlow still targets Java 1.7 (See JAVACOPTS), which doesn't support "-parameters" flag. Starting from Java 11 (default since Bazel 0.29.1), a warning message will be thrown if "-parameters" is passed. If "-Werror" also exists, the compiling action will fail. To workaround this, we override the misc value of the default java toolchain to remove "-parameters" flag.
For workaround bazelbuild/bazel#8772 with Bazel >= 0.29.1 TensorFlow still targets Java 1.7 (See JAVACOPTS), which doesn't support "-parameters" flag. Starting from Java 11 (default since Bazel 0.29.1), a warning message will be thrown if "-parameters" is passed. If "-Werror" also exists, the compiling action will fail. To workaround this, we override the misc value of the default java toolchain to remove "-parameters" flag.
For workaround bazelbuild/bazel#8772 with Bazel >= 0.29.1 TensorFlow still targets Java 1.7 (See JAVACOPTS), which doesn't support "-parameters" flag. Starting from Java 11 (default since Bazel 0.29.1), a warning message will be thrown if "-parameters" is passed. If "-Werror" also exists, the compiling action will fail. To workaround this, we override the misc value of the default java toolchain to remove "-parameters" flag.
When compiling Java protos, the following error message is emitted:
This is because we force protos to be compiled with
-source 7 -target 7
for some reason:https://github.com/bazelbuild/bazel/blob/master/tools/jdk/BUILD.java_tools#L14
then we separately add
-parameters
, which is not compatible with target level 7:https://github.com/bazelbuild/bazel/blob/master/tools/jdk/BUILD.java_tools#L53
Would be nice if we didn't spam the console. I don't see a very simple way of not putting
-parameters
on the protoc Java compile command lines, though: we don't have a catchall branch incompatible_javacopts
and we can't disable a flag there, either.The text was updated successfully, but these errors were encountered: