Method reference calls wrong method

152 Views Asked by At

I'm writing an Android app and use net.sourceforge.streamsupport:streamsupport:1.5.5 I'm using Android Studio 2.3.3 with the embedded JDK, source and target compatibility are set to 1.8.

Now I have a method reference Light::getColor that, when called, calls the wrong method (Light::getMaxColorTemperature).

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

As seen when debugging: Debugger shows wrong method call

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

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

As seen when debugging: Debugger shows correct method call

Recompiling the whole project didn't change anything. Has anyone ever seen this? I'm not sure whether this is a streamsupport problem or an Android compiler problem, and how to figure out.

0

There are 0 best solutions below