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
{{ message }}
Repository navigation
[java] UnnecessaryBoxing: False negative when another overload takes an unrelated reference type #7134
#5971 (7.17.0, the fix for #5948) added an overload check to this rule. Its last clause suppresses the warning for any overload with a reference type at the argument position:
currentParamType is always primitive at that point (early return at L243), so the clause does not check whether the boxed argument can be passed to that overload. In the sample, call(String) hides the warning, although call(value) compiles and still calls call(int) (JLS 15.12.2.3).
PMD 7.16.0 reports line 6. 7.17.0 and 7.28.0 don't.
JDK calls are affected the same way, e.g. new StringBuilder(n.intValue()) because of StringBuilder(String), and new ArrayList<>(n.intValue()) because of ArrayList(Collection).
Expected outcome:
PMD should report a violation at line 6, but doesn't. This is a false-negative.
Activity