Java Reference
In-Depth Information
In addition to merging the exported and imported packages and required bundles,
the bundle class paths are also merged. This impacts the overall class search order for
the bundle, like this:
Requests for classes in java. packages are delegated to the parent class loader;
searching stops (section 2.5.4).
1
Requests for classes in an imported package are delegated to the exporting
bundle; searching stops (section 2.5.4).
2
Requests for classes in a package from a required bundle are delegated to the
exporting bundle; searching continues with a failure (section 5.3.1).
3
The host bundle class path is searched for the class; searching continues with a
failure (section 2.5.4).
4
Fragment bundle class paths are searched for the class in the order in which the
fragments were installed. Searching stops if found but continues through all
fragment class paths and then to the next step with a failure.
5
If the package in question isn't exported or required, requests matching any
dynamically import package are delegated to an exporting bundle if one is
found. Searching stops with either a success or a failure (section 5.2.2).
6
This is the complete bundle class search order, so you may want to mark this page for
future reference! This search order makes it clear how fragments support split pack-
ages, because the host and all fragment class paths are searched until the class is found.
Fragments and the Bundle-ClassPath
The bundle class path search order seems fairly linear, but fragments do introduce
one exception. When specifying a bundle class path, you can specify embedded JAR
files, such as
Bundle-ClassPath: .,specialized.jar,default.jar
Typically, you'd expect both of these JAR files to be contained in the JAR file of the
bundle declaring them, but this need not be the case. If fragments aren't involved,
the framework ignores a non-existent JAR file on the bundle class path. But if the bun-
dle has fragments attached to it, the framework searches the fragments for the spec-
ified JAR files if they don't exist in the host bundle.
In the example, imagine that the host contains default.jar but doesn't contain spe-
cialized.jar, which is contained in an attached fragment. The effect this has on the
class search order is that the specified fragment content is searched before some of
the host bundle content.
Sometimes this is useful if you want to provide default functionality in the host bun-
dle but be able to override it on platforms where you have specialized classes (for
example, using native code). You can also use this approach to provide a means for
issuing patches to bundles after the fact, but in general it's better to update the
whole bundle.
 
Search WWH ::




Custom Search