...
This compliant solution avoids the TOCTOU vulnerability by copying the mutable input and performing all operations on the copy. Consequently, an attacker's changes to the mutable input cannot affect the copy. Acceptable techniques include using a copy constructor or implementing the java.lang.Cloneable
interface and declaring a public clone method (for classes not declared final). In cases like HttpCookie
where the mutable class is declared final ���������€š�š�š�š���������‚�š�š�š�����������‚�š�š�š�š����������€š�š�š�š�? that is, it cannot provide an accessible copy method ���������€š�š�š�š���������‚�š�š�š�����������‚�š�š�š�š����������€š�š�š�š�? perform a manual copy of the object state within the caller. See rule OBJ04-J. Provide mutable classes with copy functionality to safely allow passing instances to untrusted code for more information. Note that any input validation must be performed on the copy rather than on the original object.
...