From 0889b94aa52e1960f3133142a5e2f0b6191cdbfe Mon Sep 17 00:00:00 2001 From: Mateusz Stefanski Date: Sat, 22 Aug 2020 23:28:34 +0200 Subject: [PATCH] [doc] [java] ImmutableField: extend description, fixes #2108 --- pmd-java/src/main/resources/category/java/design.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/main/resources/category/java/design.xml b/pmd-java/src/main/resources/category/java/design.xml index 61abee3387..0a5c0485d1 100644 --- a/pmd-java/src/main/resources/category/java/design.xml +++ b/pmd-java/src/main/resources/category/java/design.xml @@ -784,7 +784,10 @@ of Object-Oriented Systems. Springer, Berlin, 1 edition, October 2006. Page 80. externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_design.html#immutablefield"> Identifies private fields whose values never change once object initialization ends either in the declaration -of the field or by a constructor. This helps in converting existing classes to becoming immutable ones. +of the field or by a constructor. This helps in converting existing classes to becoming immutable ones. +Note that this rule does not enforce referenced object to be immutable itself. A class can still be mutable, even +if all its member fields are declared final. This is referred to as shallow immutability. For more information on +mutability, see Effective Java, 3rd Edition, Item 17: Minimize mutability. 3