CRITICAL
Rule Definition
A call to 'super.clone()' ensures the clone behavior will still work.
Remediation
Review the Method definition
Violation Code Sample
class Person implements Cloneable { private String name; public Person(String name) { this.name = name; } public Person clone() { return new Person(this.name); // violation } }
Fixed Code Sample
class Person implements Cloneable { private String name; public Person(String name) { this.name = name; } public Person clone() { try { return (Person)super.clone(); // FIXED 'clone' correctly calls 'super.clone' } catch (CloneNotSupportedException e) { throw new AssertionError("Should never happen"); } } }
Reference
https://www.vojtechruzicka.com/java-cloning-problems/ https://help.semmle.com/wiki/display/JAVA/Missing+super+clone
Related Technologies
JEE
Technical Criterion
Complexity - OO Inheritance and Polymorphism
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.