Reports Double Brace Initialization. Double brace initialization can cause memory leaks when used from a non-static context, because the anonymous class created will maintain a reference to the surrounding object. It has worse performance than regular initialization because of the additional class loading required. It can cause equals() comparisons to fail, if the equals() method does not accept subclasses as parameter (see link above). And finally, before Java 9 it could not be combined with the diamond operator, because that could not be used with anonymous classes.

Example of Double Brace Initialization:


  List list = new ArrayList<>() {{
    add(1);
    add(2);
  }};