How to use @Contract annotation

I am trying to learn how to develop start-up apps fastly by using libraries and annotations. I have already experinced @NonNull, @Nullable ones.

While reading javadocs i noticed there is a @Contract annotation which has usage @Contract("null->fail") that makes compilation error if null passed.

Thats really cool feature but i cant use it because there is no annotation class in support.annotations package.

How can i get this feature? Or which library to import?

Thanks.


You need to add jetbrains' annotations jar to your classpath. You can find it in maven central or locally, in <IntelliJ IDEA Home>/lib/annotations.jar

在这里输入图像描述

链接地址: http://www.djcxy.com/p/21702.html

上一篇: 直接从Windows剪贴板获取二进制数据

下一篇: 如何使用@Contract注释