Inspectopedia 2025.2 Help

'assert' message is not a string

Reports assert messages that are not of the java.lang.String type.

Using a string provides more information to help diagnose the failure or the assertion reason.

Example:

void foo(List<Integer> myList) { assert myList.isEmpty() : false; }

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.

AssertMessageNotString
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 | Code style issues

Use the Only warn when the assert message type is 'boolean' or 'java.lang.Boolean' option to only warn when the assert message type is boolean or java.lang.Boolean. A boolean detail message is unlikely to provide additional information about an assertion failure and could result from a mistakenly entered : instead of &.

This inspection depends on the Java feature 'Assertions', which is available since Java 1.4.

Inspection options

Here you can find the description of settings available for the 'assert' message is not a string inspection, and the reference of their default values.

Only warn when 'assert' message is 'boolean' or 'java.lang.Boolean'

Default value:

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 AssertMessageNotString

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