Is it possible to monkey patch in Java?

后端 未结 9 530
有刺的猬
有刺的猬 2020-12-09 16:40

I don\'t want to discuss the merits of this approach, just if it is possible. I believe the answer to be \"no\". But maybe someone will surprise me!

Imagine you have

9条回答
  •  再見小時候
    2020-12-09 16:59

    It is totally possible to monkeypatch in Java, using Unsafe.putObject and a class finder. Wrote a blog post here:

    https://tersesystems.com/blog/2014/03/02/monkeypatching-java-classes/

提交回复
热议问题