-->

Resolve a dependency on package sun.misc with Tych

2020-06-24 10:47发布

问题:

I try to convert a Buckminster-based build to Tycho (0.19.0). In our (mirrored) target platform we have the bundle com.lmax.disruptor from http://lmax-exchange.github.io/disruptor/ which imports the package "sun.misc"

When I try to build our own bundle (that depends on com.lmax.disruptor) I get:

[ERROR] Missing requirement: com.lmax.disruptor 3.2.0 requires 'package sun.misc 0.0.0' but it could not be found

I checked many Tycho tutorials but none of them contained such a dependency. Is there a way to import that package e.g., from the executing JRE?

Workaround:

When I add the disruptor bundle as a library to my bundle then it works without problems. But this seams more like a workaround because I will have other bundles that depend on it too.

回答1:

The problem is that none of the standard OSGi execution environments exposes the package sun.misc, so the bundle using this package will not work on a standard OSGi runtime. This is what the build failure is telling you.

So if you had a standard OSGi runtime (note that Equinox is special here because of its osgi.compatibility.bootdelegation option), you'd need to tell the OSGi runtime to expose additional packages from the boot class path. A way to do this (so that Tycho also understands your intention) is to build a system bundle fragment which declares an Export-Package of sun.misc.

This has been reported to work, but I haven't tried this myself.



标签: java tycho