It seems to me that the Guice implementation does some very complicated things when working with generics. It seems like at runtime he knows about the common types used at compile time. Consider a simple example:
@Inject public void Bar(Provider<Foo> genericInjector){ ...
At run time, Guice will introduce the correct Provider
implementation here (i.e. the one that provides Foo
instances). But from what I know, common types are erased at runtime (see Erasure Type ). So, all that Guice really sees at runtime:
@Inject public void Bar(Provider genericInjector){ ....
So, how is it possible that Guice knows which Provider
implementation to introduce?
source share