Affects PMD Version: 7.0.0
Rule: UnnecessaryBoxing
Description: PMD reports "Unnecessary explicit conversion from Integer to Long" violation, but removing the explicit conversion will break compilation.
Code Sample demonstrating the issue:
@SuppressWarnings({"PMD.SystemPrintln", "PMD.NoPackage"}) public final class UnnecessaryBoxing { private UnnecessaryBoxing() { } public static void addLong(Long parameter) { System.out.println("parameter = " + parameter); } public static Integer getValue() { return 42; } public static void main(String[] args) { addLong(Long.valueOf(getValue())); // PMD complains: "Unnecessary explicit conversion from Integer to Long" //addLong(getValue()); // Does not compile: "incompatible types: Integer cannot be converted to Long" } }
Expected outcome:
PMD reports a violation at line 16 (see comment), but that's wrong. That's a false positive.
Running PMD through: Gradle
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4