A class has a cloneable() method that is not declared final, which allows an object to be created without calling the constructor. This can cause the object to be in an unexpected state.
N/A
Threat Mapped score: 0.0
Industry: Finiancial
Threat priority: Unclassified
N/A
N/A
Phase | Note |
---|---|
Implementation | N/A |
Intro: In this example, a public class "BankAccount" implements the cloneable() method which declares "Object clone(string accountnumber)":
public class BankAccount implements Cloneable{ public Object clone(String accountnumber) throws CloneNotSupportedException { Object returnMe = new BankAccount(account number); ... } }
Intro: In the example below, a clone() method is defined without being declared final.
protected Object clone() throws CloneNotSupportedException { ... }