...
| Code Block | ||
|---|---|---|
| ||
private final class PrivateClass {
private int x;
private int y;
private void getPoint() {
System.out.println("(" + x + "," + y + ")");
}
}
|
| Wiki Markup |
|---|
"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.finalize method and declares that method public, 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. One noteworthy exception to this guideline pertains to classes that implement the java.lang.Cloneable interface. In these cases, the accessibility of the Object.clone method should be increased from protected to public." \[[Sun Java Secure Coding Guidelines, guideline 1-1|AA. Java References#SCG 07]\] |
Risk Assessment
Granting unnecessary access weakens the security of Java applications.
...