Fred Kiefer schrieb:
I only follow this discussion with out any deeper knowledge of the
subject, so my suggestion may be utter nonsense. But to me it seems
that
NSAutoreleasePool does the right thing. It seems wrong to me to
return a
different selector from +instanceMethodForSelector: than from
-methodForSelector:.
If one would call:
[[aFaultedObject class] instanceMethodForSelector:@selector(release)];
one would actually get the implementation of the unfaulted object.
Yet if one would call that method directly on the faulted object,
you'd
get undefined behavior (ie most likely some kind of memory
corruption if
ivars are being accessed before some other method happens to fire the
fault).
But what NSAutoreleasePool was doing is:
[GSObjCClass(aFaultedObject)
instanceMethodForSelector:@selector(release)];
When this optimization was introduced I had to add the
implementation to
EOFault even though it shouldn't be needed. But since most other code
never saw the EOFault class (as they call -class instead of
GSObjCClass()), didn't use +instanceMethodForSelecotor: but called
methods which would trigger forwardInvocation: (just like
methodForSelector: does) that didn't much matter.