We have a new project using Java 14. Unfortunately the SpotBugs task is failing with java.lang.UnsupportedOperationException: Records requires ASM8. We’re using the latest SpotBugs plugin (id "com.github.spotbugs" version "4.3.0") which uses SpotBugs 4.0.2; according to the ./gradlew dependencies graph, it’s dependent on ASM 8.0.1 which claims to support Java 14 (https://asm.ow2.io/versions.html).
I trimmed down the build script so that ./gradlew dependencies says the only references to ASM are in SpotBugs.
It seems like an older version of ASM is being pulled in but I don’t see where/how? How do I figure out where the conflict/trouble is and what’s the right way to get SpotBugs to use ASM 8?
ASM 8.0.1 does support Java 14. However, some Java 14 features require specifying the ASM8 API.
SpotBugs has not yet upgraded from the ASM7 to ASM8 API. It’s not that you have an earlier version where ASM8 is not yet available, but that the code from SpotBugs that’s using ASM is specifying to use ASM7. It’s not possible to make SpotBugs use ASM8 unless you want to contribute to the SpotBugs project with some PRs.
Additionally, the message The following errors occurred during analysis: is only informational about errors in the SpotBugs analysis. SpotBugs can still analyze most of your classes. It just can’t analyze any Record in your project that you can now have by enabling the Java 14 preview features. The stack trace is somewhat noisy, but the message you’re seeing will not actually fail the SpotBugs tasks unless you also have other issues.
Thanks James, I see that now yes. It looks like updating to ASM8 could be as easy as a one-character change in the code but don’t know what additional changes would be wanted by the SpotBugs team. So for now our answer is going to be “don’t use features that aren’t supported by SpotBugs”.
And yeah I did verify that the whole analysis doesn’t break down, just Records.