Closed chhsiao90 closed 7 years ago
I believe this is a limitation of the technique we're using and sounds similar to issue #14. Check out my comment here since I think it's a similar situation.
Basically, in the statement:
Function<Integer, String> lambdaFunction = ctx -> ctx.getSource().toString();
Type information on the lefthand side is erased at runtime, so Function<Integer, String>
becomes Function
. So we rely on the righthand side in order to resolve the type arguments for the Function. In this case, the righthand side is an instance of Context<S, D>
, and there is not enough information on the righthand side to know what the value of S
is...
Thanks for the information. I had even tried SerializedLambda and it seems that it had same limitation too.
Knowing the limitation is good enough to me, thanks!
I had searched for issues but didn't find any similar issue. And I had tried openjdk64-1.8.0.91 and oracle64-1.8.0.101, all seems to have same problem.
For following case, at test case
shouldResolveTypesForLambda
that we cannot get the generic type of Integer when defined a lambda of Function<Integer, String>. Is that a limitation? Thanks!