Can someone please explain how some mocking libraries like power mock create proxies for private method. I looked a little into cglib but couldn't find a way to intercept private method invocation. I specifically want to know about any low level libraries or core java techniques that can be used to intercept private methods.
Asked
Active
Viewed 1,022 times
0
-
I think this question has the answer to your question http://stackoverflow.com/questions/33776369/interception-of-package-private-method-for-jdk-class-with-cglib – yaswanth Jan 20 '17 at 17:40
1 Answers
0
You don't need to intercept the call as such. Just(!) insert your code at the start of the method. (Requires a bit of fixing up for the rest of the code.) Code can be rewritten at class load time through the Java Agent API.
Having siad that, IMO for testing you are much better off splitting into smaller classes and your seam is for free.

Tom Hawtin - tackline
- 145,806
- 30
- 211
- 305