Java Reflection and the pain in Refactoring

后端 未结 9 1653
清歌不尽
清歌不尽 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:08

    As an aside, Reflection also causes issues if you want to protect your code via obfuscation. Typical obfuscation tools now require you to maintain a list of all files that you do not want obfuscated so that reflection from all the XML config files works properly.

    That said, A J2EE version of Eclipse IDE along with suitable plugins for the major frameworks like Hibernate, Spring etc will do a fairly good job of handling refactoring. Unit tests will reduce the testing cycle, but the concern is that sometimes the unit tests also depend on some XML configuration forcing you to use reflection. So it is possible to break unit tests along with your code while refactoring.

提交回复
热议问题