The purpose of LinkedBindingBuilder#toConstructor(Constructor, TypeLiteral), and in particular the meaning of the second parameter, is not adequately documented. The javadoc just says "See the EDSL examples at Binder", but there is no example there.
Reading the code, I see that the TypeLiteral supplies the type arguments for the object so that Guice can correctly compute the actual types of the object's dependencies and thereby choose the correct bindings to satisfy them. That makes sense in retrospect, but it wasn't obvious.
From mattmccutchen@google.com on November 15, 2011 22:01:04
The purpose of LinkedBindingBuilder#toConstructor(Constructor, TypeLiteral), and in particular the meaning of the second parameter, is not adequately documented. The javadoc just says "See the EDSL examples at Binder", but there is no example there.
Reading the code, I see that the TypeLiteral supplies the type arguments for the object so that Guice can correctly compute the actual types of the object's dependencies and thereby choose the correct bindings to satisfy them. That makes sense in retrospect, but it wasn't obvious.
Original issue: http://code.google.com/p/google-guice/issues/detail?id=669