KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a a static method in some legacy code, which is called by multiple clients. I obviously have no options to override it, or change behaviour through dependency injection. I am not allowed to modify the existing class. What I want to do now is change the behaviour (that method - with the same signature and return type) using reflection. Is it possible ? If not, can any design pattern rescue me ? Thanks ! EDIT : There is some confusion on what can I change/modify. I cannot change any existing class/method - but I can add more classes to the project. The best I can do with the existing classes is annotate them. This is all done to avoid breaking anything in the existing code - which means a complete round of testing for a big project. EDIT 2 : java.lang.Instrumentation is not available for Android - or else it sounds like a good fit !
Tags (comma-separated)
Save Edits
Cancel