Hacker News new | ask | show | jobs
by rwalker 4898 days ago
Seems to work fine since we're dropping in the exact same implementation instructions as would have been there otherwise, and using the same object too. That way, any ivar references still correspond to the same positions in memory.
1 comments

I misread you as running the original method on the proxy object. But if you don't, aren't you missing methods you do want to track called from methods you don't?
The trick is that we use the same original object at the same address in memory and overwrite what class it thinks it is (as opposed to wrapping it). So in a way it becomes a proxy to itself.
I see, I thought you were using the proxy as normal and had programmatically made new classes also. But you are creating an object and then setting its class to the proxy. Neat.