Inspectopedia Help

Raw use of parameterized class

Reports generic classes with omitted type parameters. Such raw use of generic types is valid in Java, but it defeats the purpose of type parameters and may mask bugs. This inspection mirrors the rawtypes warning of javac.

Examples:

//warning: Raw use of parameterized class 'List' List list = new ArrayList<String>(); //list of strings was created but integer is accepted as well list.add(1);
//no warning as it's impossible to provide type arguments during array creation IntFunction<List<?>[]> fun = List[]::new;

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.

RawUseOfParameterized
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 | Java language level migration aids | Java 5

Configure the inspection:

  • Use the Ignore construction of new objects option to ignore raw types used in object construction.

  • Use the Ignore type casts option to ignore raw types used in type casts.

  • Use the Ignore where a type parameter would not compile option to ignore the cases when a type parameter fails to compile (for example, when creating an array or overriding a library method).

  • Use the Ignore parameter types of overriding methods option to ignore type parameters used in parameters of overridden methods.

  • Use the Ignore when automatic quick-fix is not available option to ignore the cases when a quick-fix is not available.

This inspection depends on the Java feature 'Generics', which is available since Java 5.

Inspection options

Here you can find the description of settings available for the Raw use of parameterized class inspection, and the reference of their default values.

Ignore construction of new objects

Not selected

Ignore type casts

Not selected

Ignore where a type parameter would not compile

Default: Selected

Ignore parameter types of overriding methods

Not selected

Ignore when automatic quick-fix is not available

Not selected

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