Inspectopedia 2025.2 Help

Unnecessary unboxing

Reports unboxing, that is explicit unwrapping of wrapped primitive values.

Unboxing is unnecessary as of Java 5 and later, and can safely be removed.

Examples:

  • Integer i = Integer.valueOf(42).intValue();Integer i = Integer.valueOf(42);

  • int k = Integer.valueOf(42).intValue();int k = Integer.valueOf(42);

    (reports only when the Only report truly superfluously unboxed expressions option is not checked)

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.

UnnecessaryUnboxing
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

Use the Only report truly superfluously unboxed expressions option to only report truly superfluous unboxing, where an unboxed value is immediately boxed either implicitly or explicitly. In this case, the entire unboxing-boxing step can be removed. The inspection doesn't report simple explicit unboxing.

This inspection only reports if the language level of the project or module is 5 or higher.

Inspection options

Here you can find the description of settings available for the Unnecessary unboxing inspection, and the reference of their default values.

Only report truly superfluously unboxed expressions

Default value:

Not selected

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 UnnecessaryUnboxing

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