DEV Community

Discussion on: Yet another dependency injection library

Collapse
 
parthasutradhar profile image
Partha Sutradhar

That's really interesting. I've looked into the code. I really want to know how this library works. Thanks. Can you provide more details on this implementation?

Collapse
 
siy profile image
Sergiy Yevtushenko

Any runtime reflection based DI container basically nothing else than a map between types (take a look at Key class) and function which is able to instantiate such type. Such a function, in turn, may invoke other similar functions to create necessary dependencies.
This library uses several tricks to achieve high performance, but the main one is the use or run-time generated lambdas to invoke constructor (or provider method). Unfortunately, these tricks making library incompatible with JDK other than 8.
Overall, run-time dependency injection should be ditched in favor of compile-time injection.