Wiki Markup |
---|
Immutability helps to supporting security reasoning. It is safe to share immutable objects, without risk that the recipient can modify something that we are relying upon \[java:[Mettler 2010B|AA. Bibliography#MettlerReferences#Mettler 2010B]\]. |
Wiki Markup |
---|
Programmers could incorrectly expect that declaring a field or variable {{final}} makes the referenced object immutable. Declaring variables that have a primitive type to be {{final}} does prevent changes to their values after initialization (unless the unsupported {{sun.misc.Unsafe}} class is used). However, when the variable has a reference type, the presence of a {{final}} clause in the declaration only makes _the reference itself_ immutable. The {{final}} clause has no effect on the referenced object. Consequently, the fields of the referenced object can be mutable. For example, according to the _Java Language Specification_ \[java:[JLS 2005|AA. Bibliography#JLSReferences#JLS 05]\], [§4.12.4|http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.12.4], "{{final}} Variables," |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="29fcfdf645adabf2-fac262b8-4d2042e8-92f29937-1e7c561450e1e0d924d2a38f"><ac:plain-text-body><![CDATA[ | [java:[Bloch 2008 | AA. Bibliography#Bloch References#Bloch 08]] | Item 13: Minimize the accessibility of classes and members | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="56e36fe05f36cbb1-ead8598f-4c1b407e-9837a2b5-9281997eef52a92c85962cd8"><ac:plain-text-body><![CDATA[ | [java:[Core Java 2004 | AA. Bibliography#Core References#Core Java 04]] | Chapter 6 | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ebbcfbee39d55917-17f78d78-4af641de-a81cb390-7e4cea20749cfe30ec22a08d"><ac:plain-text-body><![CDATA[ | [java:[JLS 2005 | AA. Bibliography#JLS References#JLS 05]] | [§4.12.4 "final Variables" | http://java.sun.com/docs/books /jls/third_edition/html/typesValues.html#4.12.4] ]]></ac:plain-text-body></ac:structured-macro> |
| ||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bc2b47d2b7eb3a12-ef8b9030-42704735-9b46a09f-15baa502fa060d4a72bc1e45"><ac:plain-text-body><![CDATA[ | [java:[Mettler 2010B | AA. Bibliography#Mettler References#Mettler 2010B]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
...