In the Equinox OSGi Framework we allow
a fragment to attach itself to a resolved host only if it can logically
be appended to the end to of the the bundle classpath of the host. But
should we allow fragments to be attached to resolved or active hosts if
the fragment imports additional packages or requires additional bundles?
The current Equinox Framework allows for this to happen.
This can lead to unpredictable behavior
with respect to loading classes and resources from a host while it is resolved.
For example, a bundle X includes a package foo and does not import
any packages or require any bundles. Bundle X is resolved and started
within the Framework. Fragment Y is a fragment to Bundle X and it
requires Bundle Z which provides package foo. If Fragment Y is attached
to a resolved Bundle X then Bundle X will all of a sudden start loading
package foo from Bundle Z because it was required by Fragment Y.
I suggest the Framework should not allow
a fragment to attach to a resolved or active host bundle if the fragment
imports or requires anything that is not already imported or required by
the resolved host bundle. If a host bundle is refreshed then it will
become unresolved and re-resolved, at that time the new fragment bundle
should be attached to the host bundle.