A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1854 below:

[java] Rule to check for double brace initialisation · Issue #1854 · pmd/pmd · GitHub

Double brace initialisation is a pattern to initialise eg collections concisely. But it implicitly generates a new .class file, and the object holds a strong reference to the enclosing object...

Example:

 new ArrayList<String>() {{ addAll("a", "b", "c"); }};

I think, we could detect that for collections as a first step. But any instance initialiser in an anonymous class that calls only public methods of the object could be considered an instance of this code smell, if no methods are overridden.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4