somehow I have the feeling, this problem can be solved in a
different way.
If the osgi.framework.system.packages / extra is provided
including a version qualifier for JavaSE-1.8. Mostly, I see, if
provided at all, that these definitions are provided without
version attribute.
The resolver preference priorities are resolved exporter before
unresolved exporters and then versioned exports before
un-versioned.
That would mean that the system-bundle with system.packages is
always resolved, and would preferred before other bundles. If
then also a correct version is provided in the system.packages,
it should be the preferred wire before all others.
Adding an Import-Package, where an Export-Package exist, could
also lead to the situation, where the Import-Package is ignored
by the framework:
I'm not sure that class loading order is even relevant
here. The stack trace linked by Brian was an OSGi resolution
error... resolution happens before a Bundle ClassLoader is
constructed and therefore before the bundle attempts to load
any class name.
That mean finding a class to be loaded will be
initially done using the boot delegation (Step 2 in this
case). If defined correctly the following will happen:
Java 1.8 - delegate to parent class loader an load
javax.annotation from there (no matter, if you have an
bundle provided for that package)
Java 11 - cannot find javax.annotation over
boot-delegation, go on with Import-Package or
Require-Bundle
Either provide a
org.osgi.framework.bootdelegation=javax.* as property to
activate boot-delegation or you can use the existing
profiles instead.
You can find the property:
org.osgi.framework.bootdelegation there with a
definition for javax.*
To make Equinox use this profile (I dont know, if this
happens by default) via launcher, you should provide the
osgi.java.profile="">file:/<your-path>/JavaSE-1.8.profile
If you take the profile, then you have to additionally
provide the property:
osgi.java.profile.bootdelegation=override, so that
Equinox takes the profile boot delegation entries.
instead of already defined ones
With the correct boot-delegation configuration, always
that same class loader will be taken for this
constellation, no matter, if in Java 1.8 or 11. The same
applies to JAXB problems.