How to force Java to reload class upon instantiation?

后端 未结 6 1175
执念已碎
执念已碎 2020-12-04 22:52

Background:
I have a MainTest class that has many buttons, each of which instantiate a class that I am coding/testing. I want the code/test cycle for these classes to be

6条回答
  •  感情败类
    2020-12-04 23:11

    I am not sure how to do this in code, but NetBeans does have an "Apply Code Changes" button that will do this.

    However, it can only change the implementation of the class, it cannot change it's signature. This means you cannot add, remove, or change instance variables or methods. This is due to the design of the JVM which does not allow these to be changed once a class has been loaded once.

    Since NetBeans can do it, there must be a way, but I do not know how to do it manually.

    If you run in an IDE that supports this feature, you can just click the button each time you modify a class. It will then recompile that class and reload it.

提交回复
热议问题