| Wiki Markup |
|---|
According to the Java Language Specification \[[JLS 052005|AA. Java References#JLS 05]\], section 8.4.8.3 "Requirements in Overriding and Hiding": |
...
According to Sun's Secure Coding Guidelines [[SCG 072007]]:
In addition, refrain from increasing the accessibility of an inherited method, as doing so may break assumptions made by the superclass. A class that overrides the
protected java.lang.Object.finalizemethod and declares that methodpublic, for example, enables hostile callers to finalize an instance of that class, and to call methods on that instance after it has been finalized. A superclass implementation unprepared to handle such a call sequence could throw runtime exceptions that leak private information, or that leave the object in an invalid state that compromises security.
...
EX1: According to Sun's Secure Coding Guidelines [[SCG 072007]]:
One noteworthy exception to this guideline pertains to classes that implement the
java.lang.Cloneableinterface. In these cases, the accessibility of theObject.clonemethod should be increased fromprotectedtopublic.
...
References
| Wiki Markup |
|---|
\[[JLS 052005|AA. Java References#JLS 05]\] [Section 8.4.8.3, Requirements in Overriding and Hiding|http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8.3] [\[[SCG 072007|AA. Java References#SCG 07]\]] Guideline 1-1 Limit the accessibility of classes, interfaces, methods, and fields \[[MITRE 092009|AA. Java References#MITRE 09]\] [CWE ID 487|http://cwe.mitre.org/data/definitions/487.html] "Reliance on Package-level Scope" |
...