Reports static fields of a Collection type. While it's not necessarily a problem, static collections often cause memory leaks and are therefore prohibited by some coding standards.

Example:


  public class Example {
    static List<String> list = new ArrayList<>();

  }

The inspection ignores final fields initialized with immutable, fixed-size collections (e.g., Map.of(), List.of(), Collections.emptyList(), Collections.singletonMap()). These collections cannot grow and therefore cannot cause memory leaks.

Configure the inspection: