On 04/01/2008, Lucas Galfaso <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> On Jan 4, 2008 7:19 AM, Felix Meschberger <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > In Apache Sling [1] we had an issue regarding classloading [2], which we
> > could solve by using the org.osgi.framework.bootdelegation property and
> > sharing a library. Even though the solution with the bootdelegation
> > property works, we noticed an interesting situation (see also [3]):
> >
> > Consider bundle B1 exporting package P1 and Bundle B2 importing Package
> > P1. In addition the bootdelegation property is set to include P1.
> >
> > When B2 is resolved (assuming B1 is active), the Felix framework
> > correctly resolves the import of P1 to the bundle B1. When a class from
> > P1 is accessed (in both B1 and B2), the class is of course loaded
> > correctly from the parent class loader as P1 is listed in the
> > bootdelegation property.
>
> From my perspective, I think this is wrong, P1 should not be resolved
> to B1 but to the system bundle (unless there is a specific version
> constraint.) This is the reason (this is copy&paste from v4.1 of the
> standard):


it depends on the setting of the "org.osgi.framework.system.packages"
property as explained near the start of section 3.8.5 (p55 in R4.1 spec):

"However, the Framework must explicitly export relevant packages from the
parent class loader. The system property

   org.osgi.framework.system.packages

contains the export packages descriptions for the system bundle"

so if P1 is not in "org.osgi.framework.system.packages" then it would
be resolved to B1 in this particular case, because the system bundle
wouldn't automatically export P1.

3.8.5
> [...]
> The system bundle (bundle ID zero) is used to export non-java.* packages
> from the parent class loader. Export definitions from the system bundle
> are
> treated like normal exports, meaning that they can have version numbers,
> and are used to resolve import definitions as part of the normal bundle
> resolving process. Other bundles may provide alternative implementations
> of the same packages.
> [...]
>
> 3.7 Resolving Process
> [...]
> The following list defines the preferences, if multiple choices are
> possible,
> in order of decreasing priority:
> - A resolved exporter must be preferred over an unresolved exporter.
> - An exporter with a higher version is preferred over an exporter with
> a lower version.
> - An exporter with a lower bundle ID is preferred over a bundle with a
> higher ID.
>
> The system bundle better to be resolved :-p and has id 0, so if there
> is no version constraints it should resolve to this bundle.
>
> >
> > The question now is: Is it correct to resolve B2's import of P1 to B1 ?
> > Or should imported packages listed in the bootdelegation property not be
> > resolved to other bundles ?
>
> They should be resolved, but to the system bundle.


the bootdelegation property is separate from the system bundle and
"org.osgi.framework.system.packages" property - regardless of where
B2's imports are resolved, class load requests for P1 will delegate to
the parent classloader first if P1 is listed under bootdelegation

but B2's imports should still be resolved even when P1 is included in
the bootdelegation list, for flexibility and in case the parent classloader
cannot provide P1 but another bundle (or the system bundle) can.

Regards,
>   Lucas
>
> > Regards
> > Felix
>



-- 
Cheers, Stuart

Reply via email to