Back to Intellij Community

PublicStaticCollectionField

java/java-impl/resources/inspectionDescriptions/PublicStaticCollectionField.html

2025.3-rc-2529 B
Original Source

Reports modifiable public static Collection fields.

Even though they are often used to store collections of constant values, these fields nonetheless represent a security hazard, as their contents may be modified even if the field is declared as final.

Example:

public static final List<String> EVENTS = new ArrayList<>();

Use the table in the Options section to specify methods returning unmodifiable collections. public static collection fields initialized with these methods will not be reported.