Fun with method references

tom.hawtin at oracle.com tom.hawtin at oracle.com
Mon Aug 9 08:26:02 PDT 2010


On 09/08/2010 01:37, Howard Lovatt wrote:

> 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.

The generics information is still in the class file format and is 
available at link-time (and also through the reflection APIs). A 
necessary change would be for Java SE 7 to allow class files with 
methods that vary only in generics. As the method resolution magic 
happens at link-time, there is no need for objects to contain generic 
information at run-time.

OTOH, I'm not a big fan of overloading. Keep it explicit.

Tom


More information about the lambda-dev mailing list