Versions Compared

Key

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

Wiki Markup
Increasing the accessibility of overridden or hidden methods permits a malicious subclass to offer wider access to the restricted method than was originally intended.
Wiki Markup
            According to the Java Language Specification The access modifier of an overriding or hiding method must provide at least as much access as the overridden or hidden method \[[JLS 2005|AA. Bibliography#JLS 05]\], Section 8.4.8.3, "Requirements in Overriding and Hiding". 

The access modifier of an overriding or hiding method must provide at least as much access as the overridden or hidden method, or a compile-time error occurs.

The following are the allowed

The following are the allowed accesses:

Overridden/hidden method modifier

Overriding/hiding method modifier

public

public

protected

protected or public

default

default or protected or public

private

Cannot be overridden

...