Search code examples
osgipatchosgi-fragment

OSGi fragments: Patching bugs in Eclipse plug-ins


After hearing about OSGi fragments, I was wondering:

Can I use a fragment to inject a patch, that is, replace an existing class in an existing, signed bundle?

Is there documentation how to do that?


Solution

  • I haven't played around with signed bundles, but their is a way to get fragments to override classes in the host bundle. However you need to have planned for this ahead of time.

    In your Host Bundle define a Bundle-Classpath thus:

    Bundle-Classpath: jar-not-in-host.jar;.

    This jar file should not exist in the host. Then your fragment can contain a jar called jar-not-in-host.jar. When the fragment is attached the classes in the jar-not-in-host.jar will be loaded before the classes in the root of the host bundle.

    Not very nice I know, but it works.