Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
class GrantAccess {
  public static void displayAccountStatus() {
    System.out.print("Account details for admin: XX");
  }
}

class GrantUserAccess extends GrantAccess {
  public static void displayAccountStatus() {
    System.out.print("Account details for user: XX");
  }
}

public class StatMethod {
  public static void choose(String username) {
  if(username.equals("admin"))
    GrantAccess.displayAccountStatus();
  else
    GrantUserAccess.displayAccountStatus();
  }
  
  public static void main(String[] args) {
    choose("user");	
  }
}

Risk Assessment

TODOConfusing overriding and hiding can produce unexpected results.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MET00-J

?? low ??

unlikely

?? high

P??

L??

Automated Detection

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

References

Wiki Markup
\[[Tutorials 08|AA. Java References#Tutorials 08]\] [Overriding and Hiding Methods|
Sun Java Tutorial
http://java.sun.com/docs/books/tutorial/java/IandI/override.html
Image Removed
Java Puzzlers 6.48
]
\[[Bloch 05|AA. Java References#Bloch 05]\] Puzzle 48: All I Get Is Static