Contract Annotations

External annotations

IntelliJ IDEA now lets using annotations without explicitly placing them in the code. This is handy when, for example, a team works on a project, using different IDEs with IDE-specific annotations, or when working with legacy classes, or in any other case when direct annotating the code is not advisable.

With IntelliJ IDEA you can specify an external annotations storage where you place all the annotations you need and associate it with project, module or class. IntelliJ IDEA then recognizes these annotations and uses them when you compile the project.

Annotations and code inspections for preventing NullPointerExceptions

Annotations and code inspections for preventing NullPointerExceptions

The dreaded NullPointerException is one of the most common bugs in Java, and also one of the hardest to find, fix, and prevent. For Java 5, IntelliJ IDEA introduces two annotations - @Nullable and @NotNull annotations - which can help find and prevent NPEs when combined with IntelliJ IDEA's on-the-fly code inspections.
Starting from version 6.0, IntelliJ IDEA's compiler can be configured to track @NotNull annotation compliance during the application runtime, so if the @NotNull-annotated expression evaluates to null, an exception is thrown. Read more about catching NullPointerException's with annotations »

"Not requiring internationalization" annotation and intention action


You can annotate any hard-coded String literal, or even the whole method, class or package as not requiring internationalization with a special @NonNls annotation. In this case, you will not be prompted for internationalizing corresponding hard-coded values. Specially designed intention action allows you to automatically insert the annotation into the appropriate places in code.

to the top