You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UnnecessaryVarargsArrayCreation flags new String[]{...} passed to a varargs parameter as unnecessary, but in some cases the explicit array is required to disambiguate between overloaded methods/constructors. Removing it produces a compile error.
Unnecessary explicit array creation for varargs method call (UnnecessaryVarargsArrayCreation)
But applying the suggested fix (removing new String[]) does not compile:
newDemo("fibonacci", "a", "b");
Demo.java:6: error: reference to Demo is ambiguous
new Demo("fibonacci", "a", "b");
^
both constructor Demo(String,String...) in Demo
and constructor Demo(String...) in Demo match
Expected behavior
The rule should not report a violation when the target type has another overload whose parameter types would also be applicable after the array-creation is expanded into varargs, because in that case the explicit array is load-bearing for overload resolution.
Actual behavior
The rule reports the array creation as unnecessary without checking for overload ambiguity, leading users to a non-compiling fix.
changed the title [-]UnnecessaryVarargsArrayCreation false positive when removing array creates overload ambiguity[/-][+][java] UnnecessaryVarargsArrayCreation false positive when removing array creates overload ambiguity[/+]on May 16, 2026
changed the title [-][java] UnnecessaryVarargsArrayCreation false positive when removing array creates overload ambiguity[/-][+][java] UnnecessaryVarargsArrayCreation: false positive when removing array creates overload ambiguity[/+]on Aug 15, 2026
changed the title [-][java] UnnecessaryVarargsArrayCreation: false positive when removing array creates overload ambiguity[/-][+][java] UnnecessaryVarargsArrayCreation: False positive when removing array creates overload ambiguity[/+]on Aug 20, 2026
Activity
[-]UnnecessaryVarargsArrayCreation false positive when removing array creates overload ambiguity[/-][+][java] UnnecessaryVarargsArrayCreation false positive when removing array creates overload ambiguity[/+][java] Suppress CompareObjectsWithEquals dogfood violations in Unnece…
[java] UnnecessaryVarargsArrayCreation: suppress when removing array …
[java] UnnecessaryVarargsArrayCreation: suppress when removing array …
[java] UnnecessaryVarargsArrayCreation: suppress when removing array …
[java] UnnecessaryVarargsArrayCreation: suppress when removing array …
[java] Fix #6611: UnnecessaryVarargsArrayCreation ignores overload am…
[-][java] UnnecessaryVarargsArrayCreation false positive when removing array creates overload ambiguity[/-][+][java] UnnecessaryVarargsArrayCreation: false positive when removing array creates overload ambiguity[/+][-][java] UnnecessaryVarargsArrayCreation: false positive when removing array creates overload ambiguity[/-][+][java] UnnecessaryVarargsArrayCreation: False positive when removing array creates overload ambiguity[/+][java] UnnecessaryVarargsArrayCreation: add regression tests for #5069 (