Inject New Methods and Properties into Classes During Runtime

前端 未结 5 1120
日久生厌
日久生厌 2020-12-06 12:22

Is there any way we can inject new methods and properties into classes during run-time.

http://nurkiewicz.blogspot.com/2009/09/injecting-methods-at-runtime-to-java.h

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 13:03

    So if you were really crazy, you could do something like what they outline here. What you could do is load the .java file, find the correct insertion point, add whatever methods you need to, call the java compiler and reload the class. Good luck debugging that mess though :)

    Edit This actually might be of some use...

提交回复
热议问题