-
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
Compiler exception running coverage: ClassNotFoundException: org.jacoco.agent.rt.internal_b0d6a23.Offline #5426
Comments
@cushon I'm a bit puzzled by what happens here, do you have any idea what is causing this error? |
When bazel/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java Line 236 in 6c8166e
Maybe those are interfering with jacoco? It seems suspicious that the plugins are being instrumented at all, though. Do you expect instrumentation to be applied to host deps (like |
IMO they should not be instrumented, but |
Yep, we can avoid running coverage on the plugin as a workaround. Thanks |
@robfig Can you tell me more about the setup? I couldn't replicate yet. Do you have a |
I think the key thing is that a java_plugin is included in the bazel coverage command. In this case, our i18n package exports a plugin to identify common errors in using it. So: bazel coverage src/com/corp/util/... fails because "bazel coverage src/com/corpo/util/i18n/bugpatterns" fails. Assuming I am correct, the proposed solution is to ignore java_plugin targets when instrumenting code, or filter them out entirely when running coverage. |
(If that doesn't seem right or you can't immediately reproduce, I'm happy to put one together. I thought it would it would reproduce quickly/easily) |
I just ran into this as well, plugins seem to break things. (Bazel v0.21) |
Any thoughts on this? I'm still blocked on this, coverage fails for me in the identical way described here. |
seeing this as well with
|
still seeing this with 1.0
|
still seeing this with
|
I can't reproduce either. I think this will require a minimal reproduction from you for the Bazel team to be able to fix it. "Normal" Javac plugins are clearly compiled in the host config, without instrumentation. Maybe there's something wrong about how errorprone loads plugins that causes it to pick up classes from the compilation classpath? However, that would require an additional non-host dependency on the plugin, i.e., bazel query --nohost_deps "somepath(//test/target, //plugin/target)" would be non-empty. |
@ulfjack i'm haven't been able to track down what's breaking it yet, but i have made progress. here's a working lcov example with Java: https://github.com/sgammon/bazel-coverage i'm going to build on that, adding dependencies from my app until something breaks it. currently, the behaviors i'm observing are:
i am working on (1) by overlaying dependencies until my sample breaks, and working on (2) the opposite direction, by removing complexity until it works. just posting this to see if it might spur anyone into a deeper understanding than i've come across yet. |
@sgammon any progress on this? (I use bazel 2.2.0) |
@asiekkowa unfortunately, no, and now on bazel |
@asiekkowa // cc @iirina, @lberki okay, i was able to work around this issue by switching toolchains: old build --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla fixed
the error is somewhere in between these states, at least for me. having built my codebase against |
I think this is caused by using an incompatible Jacoco build included in Bazel (or java_tools). The issue is that Bazel seems to be dependent on the Jacoco build's package name (that is I only know that Jacoco hard codes the package name to the jar (even into class files I guess), so if you give Bazel a Jacoco version that has the wrong package name then Bazel will blow up with this error. |
If you go and try replace jacoco in Bazel's |
@gergelyfabian this problem doesn't always fail with the titled exception. it is worth noting that i still get an exception looking like this unless i pin my project to Jacoco |
well, it definitely seems to me like this is related to plugins. in my local project, i have the following 3 kinds of tests: 1: calling Java from Java (JUnit 5) i've now been able to determine that with the changes at for kotlin or java sources touched by plugins, though (in my case, facilitating DI), coverage just vanishes. sources i would expect to see in coverage are listed in |
okay, i've got a small code sample and the kicker is, i wasn't able to repro (yet). so the following cases work fine 1: calling Java from Java (JUnit 5) still not working: 1: calling Kotlin from Java (JUnit 5, but with micronaut plugins) obviously this leads me to believe it might simply be some condition related to Kotlin and how that layer handles plugins. since Micronaut can generate code, perhaps that step is running after jacoco, and thus, instrumentation calls are dropped? ... but that wouldn't make sense, right, because jacoco is agent-based? i'm so confused. @iirina is any of this making sense? |
@sgammon, can you post a repro for the calling Kotlin from Java issue you're seeing? Do you see the ClassNotFoundException that this bug was originally filed for? |
@ulfjack https://github.com/sgammon/coverage-repro that's a bit old, on Bazel 3.7.2, but it demonstrates each of those points above. at one point early on, yes, this exception was involved. i don't believe i had seen it for some time though. |
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 ( |
"bazel coverage" fails at 0.14.1 and 4001ddd with a compiler exception. It happens with and without
--experimental_java_coverage
, and it seems to be triggered by instrumentation of an error-prone check.Here's the scenario:
and
Here's the full error:
It seems like coverage instrumentation should ignore java_plugin targets.
This is a follow-up of #4398
The text was updated successfully, but these errors were encountered: