Resolve a dependency on package sun.misc with Tycho
Asked Answered
G

2

4

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.

Grim answered 9/12, 2013 at 11:6 Comment(0)
B
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.

Bidget answered 13/12, 2013 at 10:58 Comment(2)
I created a new fragment and and added this to the target platform. Afterwards the package sun.misc could be resolved. Thanks a lot.Grim
One way to create this fragment for consumption by Tycho is explained in this answer.Unchaste
L
0

The easiest option is to include on of the pre-built system bundles provided by diffplug in your dependencies: https://search.maven.org/artifact/com.diffplug.osgi/com.diffplug.osgi.extension.sun.misc/0.0.0/jar

More info at https://github.com/diffplug/osgiX

Lodge answered 23/12, 2020 at 10:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.