|
If you use @IgnoreJRERequirement on a method which refers to JDK 7 APIs both directly in its body and also in nested anonymous inner classes (i.e. closures), then run Animal Sniffer with org.codehaus.mojo.signature:java15:1.0, no warnings are reported for the top-level class but warnings are reported for the nested $1 types. These ought to be ignored as they are lexically contained in the annotated method.
Placing the annotation on the top-level class, rather than its method using JDK 7, actually makes it worse: now errors are reported also in this top-level class.
Workaround is to also add the annotation to the declared methods of the inner classes.
In the case of references from <init>, it is necessary to refactor to a named local class. Again annotating the type does nothing - you need to declare an explicit constructor and annotate it.
There appears to be no way to suppress an error about a reference to a generic type parameter except by using raw types; the annotation is not even available on ElementType.PARAMETER anyway.
Marking as "major" since while there are workarounds for all the issues I encountered, they clutter the code considerably, and were not simple to find.
|