You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the absence of a dependency on com.google.code.findbugs:jsr305 (or similar org.jspecify:jspecify alternative), this triggers the following warning:
[WARNING] Cannot find annotation method 'when()' in type 'javax.annotation.Nonnull': class file for javax.annotation.Nonnull not found
[WARNING] /path/to/Test.java: unknown enum constant javax.annotation.meta.When.MAYBE
reason: class file for javax.annotation.meta.When not found
The trigger seems to be this usage of reactor.util.annotation.Nullable, which is defined with reference to a few javax.annotation.* meta annotations.
The issue is not observed without -XepOpt:NullAway:JSpecifyMode=true. I could also not reproduce it with JDK 21.0.6-tem and 22.0.2-oracle, but do observe it with 23.0.2-tem and 24-open. This indicates that it's specific to JSpecify mode on JDK 23+.
The text was updated successfully, but these errors were encountered:
I can reproduce this in a standalone build, but it's hard to reproduce in a unit test, so hard to track down exactly what is going on. That said, what I think is going on is:
From JDK 23 on, more annotations get read from bytecodes via the Compiler Tree APIs, due to fixes in javac;
In JSpecify mode, we are calling one of these APIs on this method parameter that we didn't call before (due to some generics checking); and
reading the annotation via the Compiler Tree API leads to the annotation type being properly loaded by javac, which leads to its meta-annotations being loaded, which leads to the warning you are seeing.
The only part I'm not too sure about is why 2 is happening (which is hard to track down outside a unit test). But I don't think anything wrong is going on here. javac tries to be lazy about loading types / annotations from the classpath, but in principle it can load whatever is present there and whatever those types depend on. By using javax.annotations.* meta annotations, I think those annotations become part of reactor.util.annotation.Nullable's "API" and should be on the classpath to avoid such warnings.
While I haven't fully tracked this down, I'm pretty sure it's not a NullAway bug, so I'm going to close it out. Unfortunately I think you'll need the JSR305 annotations on the classpath to avoid these warnings for now.
See this discussion for context. I narrowed down the reproduction case to:
In the absence of a dependency on
com.google.code.findbugs:jsr305
(or similarorg.jspecify:jspecify
alternative), this triggers the following warning:The trigger seems to be this usage of
reactor.util.annotation.Nullable
, which is defined with reference to a fewjavax.annotation.*
meta annotations.The issue is not observed without
-XepOpt:NullAway:JSpecifyMode=true
. I could also not reproduce it with JDK21.0.6-tem
and22.0.2-oracle
, but do observe it with23.0.2-tem
and24-open
. This indicates that it's specific to JSpecify mode on JDK 23+.The text was updated successfully, but these errors were encountered: