Closed boris-petrov closed 6 months ago
Hi @boris-petrov, thank you very much for reporting this issue. This issue has been resolved within #226 which is on version 1.3.13-SNAPSHOT
. We will make a release tonight and using the new version, should fix the problem you are encountering. If the issue still persists after the upgrade, please let us know and we will try to fix it ASAP.
Regarding -i
argument, Annotator is able to infer @Initializer
methods (for more details, please see @Initializer on NullAway's wiki). NullAway will acknowledge any annotation ending with a name Initializer
on a method as an initializer annotation.
When a method is inferred to be an @Initializer
method, Annotator will add the annotation (given as argument of i
flag) on the detected method. In your case, it will add changes below:
+import com.company.Initializer
+@Initializer
public init(){....}
Please note that com.company.Initializer
must exist on the class path before the inference start. We recommend using the annotation provided with NullAway as below:
compileOnly 'com.uber.nullaway:nullaway-annotations:0.10.10'
and passing -i com.uber.nullaway.annotations.Initializer
, however, as long as the annotation is present in the classpath (and its name ends with 'Initializer'), you can select any other annotations you prefer.
If there was anything , please let me know.
Best,
Nima
@nimakarimipour thanks for the time and the detailed explanation!
I saw this PR and the fix but I thought it was handling some specific case with records (as I saw in previous commits that they were supposed to generally work). I'll await the release and will let you know if there is anything else, thanks! :)
As for the @Initializer
- now it makes sense, thanks! You might want to mention the same things you said here in the README so other people who aren't familiar with NullAway can also understand the point of that argument.
I'll close this issue, thanks for the time!
Describe the bug
That's the error I get when running
NullAwayAnnotator
on my project. After that there is a NPE:To Reproduce The code above.
Expected behavior The record
Pair
to be found.Stack trace See above.
OS (please complete the following information):
Additional context I'm not sure I'm not doing something wrong. For example, I'm not sure what the
-i
argument that I had to specify when running thejava
command is supposed to be. I just usedcom.company.Initializer
. I don't think that's the culprit here but who knows?