3 ms·
> Reflection doesn't get in the way of type safety (in fact, it's generally supported by it) Perhaps my terminology was incorrect there. It's more that it gets
by bjz_ 11y ago
> Reflection doesn't get in the way of type safety (in fact, it's generally supported by it)
Perhaps my terminology was incorrect there. It's more that it gets in the way of static verification, and makes it much harder to refactor code with confidence.
For example, I am working on a Java project at the moment, for which many constructors and methods are apparently (to the IDE's static analysis) unused. I could quite merrily delete them or change their signatures, only to have the program it break unexpectedly at runtime due to reflection expecting them to exist at the opposite end of the codebase. That is the power of static types - and reflection breaks those guarantees.