Question
The code analysis feature in IntelliJ does not recognize methods that are invoked by JVM agents. This results in false positives in the IDE's issue detection. This happens even though the implementation of annotations is clean and achieved without suppressing warnings. Sample code:
import java.lang.annotation.*;
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface @Bar
{
}
@Bar
public final class Foo {
}
How to ensure IntelliJ can acknowledge these methods as entry points for byte code manipulation?
Answer
This is currently not a default feature within IntelliJ. However, IntelliJ offers a workaround by allowing you to declare your own annotation and then add it under the Unused declaration inspection settings.
Follow the steps:
- Navigate to
Settings. - Move towards
Editor. - In the editor settings, find
Inspections. - In inspections, navigate to
Entry points. - Finally, click on
Annotations.
Alternatively, the user can use the intention to work around the issue.
This should help to reduce the amount of false positives reported in your inspections.
Comments
0 comments
Please sign in to leave a comment.