Inspectopedia 2025.2 Help

Wrapper type may be primitive

Reports local variables of wrapper type that are mostly used as primitive types.

In some cases, boxing can be source of significant performance penalty, especially in loops.

Heuristics are applied to estimate the number of boxing operations. For example, conversions inside loops are considered as much more numerous.

Example:

public void example() { Integer value = 12; needBox(value); for (int i = 0; i < 10; i++) { // Loop usages considered as happening more often needPrimitive(value); } } void needPrimitive(int value) {} void needBox(Integer value) {}

After the quick-fix is applied:

public void example() { int value = 12; needBox(value); for (int i = 0; i < 10; i++) { // Loop usages considered as happening more often needPrimitive(value); } } void needPrimitive(int value) {} void needBox(Integer value) {}

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.

WrapperTypeMayBePrimitive
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 | Performance

New in 2018.2

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 WrapperTypeMayBePrimitive

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.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025