简体   繁体   English

使用 Tycho 解决对包 sun.misc 的依赖

[英]Resolve a dependency on package sun.misc with Tycho

I try to convert a Buckminster-based build to Tycho (0.19.0).我尝试将基于 Buckminster 的构建转换为 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"在我们的(镜像)目标平台中,我们有来自http://lmax-exchange.github.io/disruptor/的包 com.lmax.disruptor,它导入包"sun.misc"

When I try to build our own bundle (that depends on com.lmax.disruptor) I get:当我尝试构建我们自己的包(这取决于 com.lmax.disruptor)时,我得到:

[ERROR] Missing requirement: com.lmax.disruptor 3.2.0 requires 'package sun.misc 0.0.0' but it could not be found [错误] 缺少要求:com.lmax.disruptor 3.2.0 需要“package sun.misc 0.0.0”但找不到

I checked many Tycho tutorials but none of them contained such a dependency.我检查了许多第谷教程,但没有一个包含这样的依赖项。 Is there a way to import that package eg, from the executing JRE?有没有办法从正在执行的 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.但这更像是一种解决方法,因为我也会有其他依赖它的包。

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.问题是标准 OSGi 执行环境都没有公开包sun.misc ,所以使用这个包的包不能在标准 OSGi 运行时上工作。 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.因此,如果您有一个标准的 OSGi 运行时(请注意,Equinox 在这里很特别,因为它的osgi.compatibility.bootdelegation选项),您需要告诉 OSGi 运行时从引导类路径公开其他包。 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 .这样做的一种方法(以便第谷也理解您的意图)是构建一个系统包片段,它声明了sun.miscExport-Package

This has been reported to work, but I haven't tried this myself.据报道这有效,但我自己没有尝试过。

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最简单的选择是在您的依赖项中包含 diffplug 提供的预构建系统包: 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更多信息请访问https://github.com/diffplug/osgiX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM