public
and mutable.
This class has been annotated with the annotation Immutable, from the JCIP annotations package. A public field of a mutable type allows code external to the class to modify the contents and violate the immutability of the class.
Example 1: The following code for an immutable final class mistakenly declares a Set public
and final
.
@Immutable
public final class ThreeStooges {
public final Set stooges = new HashSet();
...
}
[1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 471
[2] B. Goetz Java Concurrency in Practice. Chapter 3: Sharing Objects Guidelines
[3] Package net.jcip.annotations Specification