Fun with method references
Howard Lovatt
howard.lovatt at gmail.com
Sun Aug 8 17:37:57 PDT 2010
>>> void foo(Handler<String> stringHandler) { ... }
>>> void foo(Handler<Bar> barHandler) { ... }
>>>
>>> which exhibits exactly the same erasure problem.
>>>
>>
>> Exactly. I strongly believe that we need function types.
>> Whatever restrictions that are put upon them due to
>> erasure, will be lifted whenever we get erasure.
>
> I don't understand how reification would help here. Isn't overloaded
> method resolution resolved at compile time? So if there is a problem
> with overloading, shouldn't this problem be solved at compile time?
The problem is that both foo(Handler<String>) and foo(Handler<Bar>)
get erased to foo(Handler) and therefore they both can't exist in the
same class (they have the same signature in the class file). If
generics ere reified then you could have both methods in the same
class since they would have different signatures. The same goes for
any other feature, including function types, that is implemented via
erasure.
-- Howard.
More information about the lambda-dev
mailing list