Java Reflection and the pain in Refactoring

后端 未结 9 1651
清歌不尽
清歌不尽 2021-02-08 14:25

Java Reflection provides a mechanism to introspect an Object at runtime. No second thoughts, this is a great feature, but it breaks all the Refactoring conventions!

Ther

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 15:09

    Well, it's another opportunity for IDE makes to sell expensive premium versions which will recognize and refactor class names used in specific configuration files.

    Alternatively, such recurring cases can be handled by a test suite that performs sanity checking on such files, i.e. checks that all referred classes and methods exist. Such are specific to one file format, but are often relatively easy to write and can then be used to check all files of that format.

    But there is no general solution for the direct, "manual" use of the reflection API - which is why it's generally discouraged.

提交回复
热议问题