Not able to recognize JDK 8 Static Method References
A source code analyzer
Brought to you by:
adangel,
juansotuyo
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.
This will be fixed with the next release.