Wednesday, April 24, 2013

On the evilness of split packages in the OSGi

OSGi allows for having packages split across multiple bundles. This, together with a dropins mechanism, is a true mine field.

So, what's wrong with those split packages? They are split! OSGi, in some magic way, merges them during runtime, but does not see explicit dependency between bundles providing those packages.

The P2 reconciler app, using some Equinox service, refreshes all packages that have dependency changed. So, for example, if you install a bundle providing javax.xml into dropins, you'll have almost all plugins refreshed (depending on the dependency tree).

But, since bundles with split packages are not dependent on each other, you may end up in a not so much theoretical situation, were a bundle with one split package is refreshed, and the other is not. If they do depend on each other (f.e. one has an implementation, the other an interface) you will get a nice ClassCastExceptions or other, similar runtime errors.

Real Eclipse bug can be found in the Eclipse bugzilla.


  1. You might want to tell the Eclipse folks this.
    And while you're at it, please also ask them to refrain from using 'Require-Bundle', that one might even be more evil than split packages

    A bndtools developer..


    1. Require-Bundle are hardcoded in too many places at Eclipse (and as an Eclipse packager I prefer them over import package ;-) ).

    2. You like Require-Bundle but you hate split packages? This doesn't make sense. Require-Bundle is the "gateway drug" for split packages. Without R-B, splits are not even possible because Import-Package only ever selects one provider for a package.

      Require-Bundle was only added to OSGi in R4 to keep Eclipse happy, and look where it got us....

    3. I think we should ask the OSGi Alliance to rename the 'Require-Bundle' header to 'You-Are-Doing-It-Wrong'

    4. Neal,
      At that time as I was barely an Eclipse user. I prefer them over I-P because R-B was easier to diagnose. I-P was quite awful because of split packages :D. I guess I was not aware of what was the problem and what was the cause.

      Ferry, +1