Reputation: 13666
I use the dependency for the CheckerFramework in Java for a Spring application
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>1.9.4</version>
</dependency>
in a Maven project under IntelliJ. I installed the plugin for IntelliJ, available here. However, when I add an annotation, e.g.
import org.checkerframework.checker.igj.qual.ReadOnly; import org.checkerframework.checker.nullness.qual.NonNull;
@Service public class AService {
@Override
public void addSomething(final int[] @NonNull @ReadOnly something) {}
I get the message Annotations are not allowed here
and I cannot compile. I already turned on all the annotations for the plugin.
How can I solve this?
Upvotes: 0
Views: 761
Reputation: 8117
The syntax you have written is not legal Java.
Annotations on the array type are written before the array brackets, not after them.
If you wish to indicate that something
is a non-null array of ints, then don't write int[] @NonNull something
. Instead, write it like this:
int @NonNull [] something
Upvotes: 2