invalid functional descriptor - method is generic

Olexandr Demura oleksander.demura at gmail.com
Thu Nov 8 05:32:57 PST 2012


Could you please explain motivation behind restriction on generic methods
yo not being able to use define functional interface as SAM?

I tried to expose java.util.Mapping as functional interface thru CPS,
but it happened to not work - errors on both `Both` definitions.

java: incompatible types: invalid functional descriptor: method
<U>fold(lamb.da.data.bi.Combiner<K,V,U>) in interface lamb.da.data.bi.Both
is generic.

public interface Both<K, V> extends Mapping<K, V>, BiFunctee<K, V> {
<U> U fold(Combiner<K, V, U> c);

@Override
K getKey() default { return fold((k, v) -> k); }

@Override
V getValue() default { return fold((k, v) -> v); }

@Override
<U, W> Both<U, W> map(
Mapper<? super K, ? extends U> m,
Mapper<? super V, ? extends W> n
) default {
Both<K, V> this0 = this;
return c -> this0.fold(c.precombine(m, n));
}

@Override
Both<V, K> swap() default {
final Both<K, V> this0 = this;
return (m) -> this0.fold((K k, V v) -> m.combine(v, k));
}

}

openjdk version "1.8.0-ea"
OpenJDK Runtime Environment (build
1.8.0-ea-lambda-nightly-h1669-20121030-b63-b00)
OpenJDK 64-Bit Server VM (build 25.0-b05, mixed mode)

Note, I code that for fun, not for highly loaded production system;
none of which supports lambdas anyway since java8 is a toy yet.


More information about the lambda-dev mailing list