I have an interesting problem. I would like to change the behaviour of some builtin class dynamically. Here is an example:
I want to change the behaviour of the "get current time" procedure in Java. I want to mock it to return 01-01-2022 12:30 if some condition is true. My intuition tells me that I need to use reflection overwriting + Proxies but I am still not sure which API can give me this flexibility. I don't know two things: What is the method that is being called to get the current time? How to "patch" method's class to be actually my Proxy?
Thanks in advance!
I checked the docs for both reflection and Proxies and I still have no clue on how to proceed.
Aucun commentaire:
Enregistrer un commentaire