free reign over all instances. To prevent this sort of attack,do not use the clone method to make a defensive copy of a parameter whose type issubclassable by untrusted parties.РWhile the replacement constructor successfully defends against the previous attack, it is stillpossible to mutate a Period instance because its accessors offer access to its mutable internals:Р// Second attack on the internals of a Period instanceРDate start = new Date();РDate end = new Date();РPeriod p = new Period(start, end);Рp. end(). set Year (7 8); // Modifies internals of p!РTo defend against the second attack, merely modify the accessors to return defensive copiesof mutable internal fields:Р// Repaired accessors - make defensive copies of internal fieldsРpublic Date start() (Рreturn (Date) start.clone();Р}