First, a method can never ignore packaging instructions.
Second, the historic decision was that the problem (of marshalling external data) was implemented as a class hierarchy, without use of a registry.
Third, the method allFormats is not greedy. The method allFormats delivers all concrete children, for two purposes: a) at runtime, for the decision which concrete class processes a given input and b) at package time, which classes are not referenced directly but are to be included by the packager to realize a). So greedy is the unreflected use of the method as input for the packaging rule.
Short excursus 1: at the time of this coding of
CgImageSupport (1995-96)
* only a few of us heard about "design patterns" and this is an example of a factory.
* and packaging needed some support to treat such particular factory problems.
This initially lead to providing the epClassReferenceAdjustmentsFor:in: protocol, which a little bit later (Envy 5.0) became obsolete.
Here we see an example, why. There still exist three area where it is still in use (see elsewhere in my response)
One correct way to handle this packaging problem is
a) every packaging instruction in an application has to be restricted to its own classes to avoid cross impacts. That means, a protocol like
epClassReferenceAdjustmentsFor:in: in an application should not treat foreign classes, the result of allFormats has to be filtered out.
b) if an application extends the hierarchy, it must react similar, e.g. do the same thing, contain another, its own packaging instruction dealing its own extension, in the same way, e.g. filtering out the resuls of allFormats for its own classes.
Short excursus 2: a critic of using a hierarchy to implement a factory, to make use of polymorphism: naturally this leads to a pattern (or rule) how to package it, but we see here such a common rule has to be restricted to the scope of the package (and there is no way to express this in general, such a rule has to be added to the global package instruction, not per application).
End of excursus,
Finally, an important question is the purpose of the Class GbtPNGFileFormat, the cause of this dilemma?
a) if it is not needed, it should not be loaded (so to bypass the faulty parametrisation of the call of epClassReferenceAdjustmentsFor:in:).
b) if it is needed, then it must be listed as a prerequisite or included to be part of the package.
My suspicion is (let me know if I am incorrect):
this class GbtPNGFileFormat provides a method with a (temporary) fix of a code (in CgImageSupport) to be packaged.
If this is the case, then it is needed (see b) before).
Now repairing a brittle factory construct in frameworks is an art, as we can see here.
It is not sufficient to subclass a defect.
It requires also to care about collatoral impacts, the packaging rule of CgImageSupport demonstrates this.
Excursus 3 about the aspect of privacy of classes: the file format classes are candidates. If they would have been declared private classes, the whole problem would not exist, as the given package rule would not silently extend to other foreign classes, as those could not subclass a private class.
But I guess the design of the hierarchy was made with the idea of extensibily in mind: what if there is another new format to be supported?
So private class was not an option. Instead that was vaguely left open to be able to later add subclasses on demand.
However, that does not solve the (initial) factory decision, which class is to be used for a given input. Eg. the decision has also to be made extendable, allFormats alone won't do. The construct is conceptually incomplete. A reason of the (packaging) instability.
Conclusion: a old proverb saying "never touch a running system" led to a bunch of problems - even the existance of an initially
unsuspicious class is abe to crash the packaging process.
Did you ever thing about directly replacing the faulty method?
A) directly edit code at the source, make a scratch edition of CgImageSupport and use your own fix when packaging, as long as a fix is officially released).
B) instead of manipulation foreign source, just swap the faulty method, replace the compiled method of CgImageSupport, e.g. when you are loading it in your image.
Depending on other implications, decide what and how to patch. Subclassing is not an ideal way to do this.
Let me know if there is something left to be discussed about this incidence.