Why @Nonnull annotation checked at runtime?

后端 未结 1 1303
[愿得一人]
[愿得一人] 2020-12-08 05:57

I have a function with following signature

public static String myFunction(@Nonnull String param)

When I call it with param as null, I get

相关标签:
1条回答
  • 2020-12-08 06:58

    When you compile your project in IntelliJ IDEA, it instruments the bytecode of compiled classes to add runtime checks for various flavors of @Nonnull annotations. This behavior is controlled by the option:

    Settings | Build, Execution, Deployment | Compiler | [x] Add runtime assertions for not-null-annotated methods and parameters.

    0 讨论(0)
提交回复
热议问题