The writer of an annotation can set one of three retention policies for it:

Only annotations that have been given a RUNTIME retention policy will be available to reflection. Testing for annotations with any other retention policy is simply an error, since the test will always return false.

This rule checks that reflection is not used to detect annotations that do not have RUNTIME retention.

Noncompliant Code Example

Method m = String.class.getMethod("getBytes", new Class[] {int.class,
int.class, byte[].class, int.class});
if (m.isAnnotationPresent(Override.class)) {  // Noncompliant; test will always return false, even when @Override is present in the code