3 ms·
(I got lucky and spotted this reply instantly; I promise I wasn't lurking waiting for a reply.) Don't dynamic DI frameworks like Spring use runtime reflection
by Twisol 5y ago
(I got lucky and spotted this reply instantly; I promise I wasn't lurking waiting for a reply.)
Don't dynamic DI frameworks like Spring use runtime reflection to invoke such constructors? If a bug existed in Spring causing a value of the wrong type to be provided, I expect it would go undetected until runtime, at which point Java will throw an exception.
My understanding of "type safe" is that the code is statically known not to have such defects. It's likely that we're just getting hung up on definitions.
- The_Colonel 5y agoYes, that's the case in Spring. But there are DI containers which are statically safe, e.g. Dagger.
- kaba0 5y agoYeah of course it depends on your definition — and in case of such a widely used framework I would usually use type safe with regards to user code, but you are entirely right! But another point I had in mind is regarding the JVM is that it is strongly typed so such an error will be at least visibly and fail with a proper error message.