PlugIn behavior: Strange but Extremely Sexy!
PlugIn behavior: Strange but Extremely Sexy!
- Subject: PlugIn behavior: Strange but Extremely Sexy!
- From: email@hidden
- Date: Sat, 26 Oct 2002 21:19:00 -0400
I have been experimenting with PlugIns, and I have come across some
interesting behavior:
There are three plugins: superPlugIn.bundle,
superPlugInSubstitute.bundle, and subPlugIn.bundle;
The superPlugIn.bundle and superPlugInSubstitute.bundle both implement
a class called SuperPlugIn that has one method: doSomethingCool that
looks different for each implementation:
superPlugIn.bundle:
- doSomethingCool
{
NSLog(@"Hello World!"); //I know, that's not very cool.
}
superPlugInSubstitute.bundle:
- doSomethingCool
{
NSLog(@"!dlrow olleH"); //That's a little more like it!
}
The subPlugIn.bundle implements a class called SubPlugIn that does
nothing but inherit from SuperPlugIn.
The program that these are loaded into checks for and then calls the
doSomethingCool method of each class, so loading in superPlugIn.bundle
and then subPlugIn.bundle produces:
Hello World!
Hello World!
Likewise, loading in superPlugInSubstitute.bundle and then
subPlugIn.bundle produces:
!dlrow olleH
!dlrow olleH
The first strange thing is that subPlugIn.bundle can be loaded in
without superPlugIn(Substitute).bundle being loaded in before it or
even at all (though it doesn't produce anything, because there is no
inherited method).
The second strange thing is that all three or both superPlugIn.bundle
and superPlugInSubstitute.bundle can be loaded into the program at the
same time without a class conflict (depending on the loading order,
they put out their output).
Why are these two strange scenarios possible (and can they be reliably
exploited?).
Is it always the case that a subclass loaded in doesn't need to have
its superclass loaded in first (provided no message is sent to it)?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.