Inspectopedia 2025.3 Help

Type may be weakened

Reports variable and method return types that can be changed to a more abstract (weaker) type. This allows making the code more abstract, hence more reusable.

Example:

// Type of parameter can be weakened to java.util.List void processList(ArrayList<String> list) { if (list.isEmpty()) return; System.out.println("Processing"); for (String s : list) { System.out.println("String: " + s); } }

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.

TypeMayBeWeakened
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 | Abstraction issues

Enable the Only weaken to an interface checkbox below to only report a problem when the type can be weakened to an interface type.

Enable the Do not suggest weakening variable declared as 'var' checkbox below to prevent reporting on local variables declared using the 'var' keyword (Java 10+)

Stop classes are intended to prevent weakening to classes lower than stop classes, even if it is possible. In some cases, this may improve readability.

Inspection ID: TypeMayBeWeakened

Inspection options

Here you can find the description of settings available for the Type may be weakened inspection, and the reference of their default values.

Only weaken to an interface

Option ID:

onlyWeakentoInterface

Default value:

Selected
Do not suggest weakening variable declared as 'var'

Option ID:

doNotWeakenInferredVariableType

Default value:

Not selected
Stop classes

Option ID:

myStopClassSet

Default value:

None

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection TypeMayBeWeakened

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025