Method refers to an invalid method

I am writing an Android application and using net.sourceforge.streamsupport:streamsupport:1.5.5 I am using Android Studio 2.3.3 with built-in JDK, the source and target compatibility is set to 1.8.

Now I have a method reference Light::getColorthat, when called, calls the wrong method ( Light::getColorTemperature).

return StreamSupport.stream(lights)
    .filter(light -> light.getColorMode().ordinal() >= ColorMode.HUE_SATURATION.ordinal()
    .findFirst()
    .map(Light::getColor)
    .orElse(Color.WHITE);

As you can see when debugging: Debugger shows an invalid method call

If I use the lambda ( light -> light.getColor()) expression instead , the correct method is called:

return StreamSupport.stream(lights)
    .filter(light -> light.getColorMode().ordinal() >= ColorMode.HUE_SATURATION.ordinal()
    .findFirst()
    .map(light -> light.getColor())
    .orElse(Color.WHITE);

As you can see when debugging: The debugger shows the correct method call

Recompiling the entire project has not changed anything. Has anyone ever seen this? I'm not sure if this is a streaming problem or a problem with the Android compiler, and how to find out.

+4
source share

Source: https://habr.com/ru/post/1681402/


All Articles