I wrote a simple project to learn how to work with annotation validation. For that puspose I added maven dependency (also I tried javax.validation, that does not work for me):
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>15.0</version>
</dependency>
and used it this way:
public boolean add(@NotNull T entry){ ...
When I build the project from IDEA, everything is fine, but it does not work when compiling the code with maven command. In decompiled class file I noticed that IDEA compiles my classes in different way. It adds this check:
if (entry == null) {
$$$reportNull$$$0(0);
}
And maven does not.
I'm I doing something wrong? Please, tell me how it should be used (no matter jetbrains or javax validation).
Partially guessing here: you see, it is not "IDEA" that puts that extra check into the byte code.
The thing is: annotations can also be used to generate code (see here for some further reading). And as you can see from that link; the core thing for code generation is: that annotation requires a javax.annotation.processing.Processor class. And that will be used by the compiler to turn the source code annotation into something reasonable within byte code.
If I get you right, you failed to get those javax parts setup for your maven compile. So probably the one part is missing there; so the solution is to fix your maven setup to provide all required dependencies.