Skip to content

[java] UnusedPrivateMethod: False positive with raw type for generic method #6028

@Pankraz76

Description

@Pankraz76

Affects PMD Version: PMD 7.14.0

Rule: UnusedPrivateMethod

Description:

Code Sample demonstrating the issue:

import java.util.Collection;

public final class addAllImpl {
  private static abstract class Multiset<K> extends Collection<K> { }
  static <E> boolean addAllImpl(
      Multiset<E> self, Collection<?> elements) {
    return addAllImpl(self, (Multiset) elements);
  }

  private static <E> boolean addAllImpl(
      Multiset<E> self, Multiset<E> elements) {
  }
}

Expected outcome:

PMD reports a violation at line 10, but that's wrong. That's a false positive.

Running PMD through: maven-pmd-plugin 3.27.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions