Menu

#1247 Not able to recognize JDK 8 Static Method References

PMD-5.1.3
closed
None
PMD
2-Critical
Bug
5.1.2
2014-08-31
2014-08-20
subhajit
No

PMD is not able to recognize the implementation of functional interface via static method reference.

Sample code:

KeyMap keymap = maps.getKeyMap();

if (obj.getParamTypes()
.stream().allMatch(keymap::booleanFunc))
{
// do something
}

=====================

public KeyMap
{
public boolean booleanFunc(ParamType type)
{
return true;
}
}

On running PMD analysis following warning is thrown:
Avoid unused local variables such as 'keymap'.

This is wrong as keymap is used as a Static Method References for creating the predicate functional interface which is feed to .stream().allMatch() method. The code is compiling fine too.Here keymap is not a unused variable, please rectify this.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-08-22
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: PMD-5.1.2 --> PMD-next
     
  • Andreas Dangel

    Andreas Dangel - 2014-08-22

    This will be fixed with the next release.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.