CRITICAL
Rule Definition
When annotating a class with @Immutable from JCIP package, one might incorrectly assume that all its fields are immutable.
Remediation
Explicitly set the final attribute to the public fields.
Violation Code Sample
import net.jcip.annotations.Immutable;
@Immutable
public class MyClass {
public int myInt; // VIOLATION
}
Fixed Code Sample
import net.jcip.annotations.Immutable;
@Immutable
public class MyClass {
public final int myInt; // FIXED
}
Reference
CWE-471: Modification of Assumed-Immutable Data (MAID)
https://cwe.mitre.org/data/definitions/471.html
Related Technologies
Technical Criterion
Secure Coding - API Abuse
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.