Versions Compared

Key

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

...

The access modifier of an overriding or hiding method must provide at least as much access as the overridden or hidden method (The Java Language Specification, §8.4.8.3, "Requirements in Overriding and Hiding" [JLS 2015]). The following table lists 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

...

This compliant solution declares the doLogic() method final to prevent malicious overriding:

...