Skip to content

[java] UnnecessaryBoxing false positive when calling List.remove(int) #5948

Closed

Description

@UncleOwen

Affects PMD Version: 7.16.0

Rule: https://pmd.github.io/pmd/pmd_rules_java_codestyle.html#unnecessaryboxing

Description: The following code triggers UnnecessaryBoxing. If I remove the call to .intValue(), the wrong overload of ArrayList.remove() is called.

Code Sample demonstrating the issue:

        List<String> l = new ArrayList<>();
        Integer i = 3;

        l.remove(i.intValue());

Expected outcome:

No violation

Running PMD through: IntelliJ-Plugin

Activity

  1. added
    a:false-positive
    on Jul 29, 2025
  2. changed the title [-][java] False Positive in UnnecessaryBoxing[/-] [+][java] UnnecessaryBoxing false positive when calling `List.remove(int)`[/+] on Jul 31, 2025
  3. added this to the 7.17.0 milestone on Aug 8, 2025
  4. added a commit that references this issue on Aug 8, 2025
    64ef399
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positive

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions