-
Notifications
You must be signed in to change notification settings - Fork 4k
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
bad path element
warnings when compiling java with bazel 4
#12968
Comments
/cc @cushon - This feels like your corner of the world? |
Digging deeper, the problem appears to be this line in BlazeJavacMain where, no matter what the flags passed in |
Removing the line where lint checking of paths is enabled leads to incorrect warnings about strict java deps violations, so I think that there's more to the fix than simply deleting the extra option. |
I have same issue. And after some code navigation, I found that the only way around that is to pass the undocumented (to the extent of my knowledge) |
cc @comius
I think part of the issue with If you're using
@kdehairy can you expand on that? I'm not sure which distinction that is. |
@shs96c I'm a little surprised by that and am having trouble repro'ing, do you have any more context on the strict deps errors you saw when you tried that? |
I can repro:
|
@cushon I just rebuilt the java builder binary from source with the change to I'm curious about why the flag is set: the commit doesn't really explain the reasoning, but it doesn't seem arbitrary. |
@cushon What I mean is With the |
TL;DR I agree this is something that should be improved, the following is mostly context about how we got here / some of the requirements that fb0f51d doesn't provide context on. @shs96c do you remember if you built and ran it at head using the re: the flag always being set, it's related to the filemanager options processing bug I mentioned in #12968 (comment) noticed this because there's a test to ensure If the only situation where this diagnostic is occurring in bazel builds is with @kdehairy thanks for the context. One of the problems the |
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
Normally, bazel uses `ijar` to prepare a jar containing just ABI-entries for classfiles. These are stable when non-API breaking changes are made, and so allow bazel to compile code faster, and are known as "compile jars" Because of bazelbuild/bazel#4549 `rules_jvm_external` doesn't use `ijar`, and instead uses the downloaded jar as the "compile jar". Normally, this is fine, but Bazel 4.0.0 now sets `-Xlint:path` for javac invocations, and this means that if there's a `Class-Path` manifest entry in a compile jar, the jars within _that_ will be checked. This can lead to noisy builds: bazelbuild/bazel#12968 This change generates a "pseudo-compile jar" for `jvm_import` targets. All it does is repack the input jar, excluding the `META-INF/MANIFEST.MF` file. This means that we should avoid compilation problems whilst still working well with Kotlin projects.
is that really noise? I'm also seeing bad-path elements with 4.0.0 but the files are non-existent like in xalan example from @uri-canva - when running the build the jvm also throws classpath-exceptions. in maven this works fine, there is probably a bug somewhere else? Is this related to optional dependencies like for xalan: https://mvnrepository.com/artifact/xalan/xalan/2.7.2 fwiw in 3.7.2 there are no warnings but the jvm still doesn't find the jars in the classpath and throws classnotfound exceptions. from my (very limited) perspective this a bug in resolving transitive dependencies - either those are there or not, but listing them in the classpath without jars looks sketchy? |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team ( |
Description of the problem / feature request:
When compiling java code with bazel 4, builds occasionally produce spurious
bad path element
warnings in an otherwise clean build. This behaviour wasn't seen in bazel 3.7.2.The warnings is typical of a problem caused by
javac
attempting to interpret theClass-Path
manifest attribute and being unable to locate jars mentioned there. This should be disabled by either compiling with-nowarn
or by setting the-Xlint:-path
flag (both on thejavac
invocation). Neither of these approaches prevents the warning being emitted by the bazel build.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I have attached a minimal sample project that demonstrates the problem. The readme of this example contains reproduction steps, but it is sufficient to do a clean build (without any cached state) of
bazel build //...
to see the problem occur.bazel-bad-path-element.zip
What operating system are you running Bazel on?
macOS Big Sur
What's the output of
bazel info release
?release 4.0.0
Have you found anything relevant by searching the web?
The flags can be found by using your favourite search engine to search for "java bad path element"
The text was updated successfully, but these errors were encountered: