Inspectopedia Help

Design for extension

Reports methods which are not static, private, final or abstract, and whose bodies are not empty.

Coding in a style that avoids such methods protects the contracts of classes from being broken by their subclasses. The benefit of this style is that subclasses cannot corrupt the state of the superclass by forgetting to call the super method. The cost is that subclasses are limited in their flexibility, in particular they cannot prevent execution of code in the superclass. Use the quick-fix to add the missing modifiers.

Example:

class Foo { public boolean equals(Object o) { return true; } }

After the quick-fix is applied:

class Foo { public final boolean equals(Object o) { return true; } }

This inspection is intended for code that is going to be used in secure environments, and is probably not appropriate for less restrictive environments.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

DesignForExtension
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Security

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.2, Qodana for JVM 2024.2,

Can be installed with plugin:

Java, 242.22892

Last modified: 11 September 2024