Menu

#1295 False Positive when using this::methodCall

3.0.1
closed-fixed
jdk 1.8 (1)
5
2015-01-12
2014-08-07
No

The example I have failing:

public List<AncestorNodeReference> getAncestors()
{
...
List<AncestorNodeReference> ancestorNodes =
ancestorNodeDTO.getAncestors().stream()
.map(this::createAncestorNodeReference)
.collect(Collectors.toList());
...
}

private AncestorNodeReference createAncestorNodeReference(
final AncesterNodeReferenceDTO ancestorNodeRefDTO)
{
return createAncestorNodeReference(
ancestorNodeRefDTO.getNodeId(),
ancestorNodeRefDTO.getNodeName(),
ancestorNodeRefDTO.getAspectId(),
ancestorNodeRefDTO.getAspectName());
}

private AncestorNodeReference createAncestorNodeReference(
final UUID nodeId,
final String nodeName,
final UUID aspectId,
final String aspectName)
{
...
}

The findbugs error:

Details

UPM_UNCALLED_PRIVATE_METHOD: Private method is never called

This private method is never called. Although it is possible that the method will be invoked through reflection, it is more likely that the method is never used, and should be removed.

It claims that the method createAncestorNodeReference that takes the AncestorNodeReferenceDTO is never called, when in fact it is called by: this::createAncestorNodeReference.

The findbugs version I am using is 3.0.0.
I am using Java version 1.8.0_11 on Ubuntu 12.04.

Related

Bugs: #1370

Discussion

  • Andrey Loskutov

    Andrey Loskutov - 2014-08-31
    • status: open --> open-accepted
     
  • Tagir Valeev

    Tagir Valeev - 2015-01-12

    Full support of invokedynamic is far from being complete in FindBugs, but this particular problem can be easily fixed simply by scanning the class constant pool for MethodHandle_info entries. If there's a MethodHandle entry pointing to the method, then the method is used. We don't know where it's used exactly, but we don't need this information for this bug.

    Committed:
    https://code.google.com/p/findbugs/source/detail?r=28682e92d2890731e4478128dd035a8aeb6d582c

     
  • Tagir Valeev

    Tagir Valeev - 2015-01-12
    • labels: --> jdk 1.8
    • status: open-accepted --> closed-fixed
    • assigned_to: Tagir Valeev
    • Group: 3.x --> 3.0.1
     

Log in to post a comment.