Inspectopedia
 
2024.3

Iterable is used as vararg

Warning
New
Last modified: 03 December 2024

Reports suspicious usages of Collection or Iterable in vararg method calls.

For example, in the following method:

a call like

looks suspicious as the list will be wrapped into a single element array. Such code can be successfully compiled and will likely run without exceptions, but it's probably used by mistake.

This inspection depends on the Java feature 'Variable arity methods', which is available since Java 5.

New in 2019.2