如何从 OSGI 包访问内部 sun.security 类?
我需要向 Maven 构建或 Java 运行时添加哪些选项才能访问内部 sun.security 类? OSGI 捆绑包中有来自 Akamai 的 Java 代码需要访问内部 sun.security 类。 Apache Felix 控制台给出了 OSGI 包的错误:
sun.awt.image.codec -- Cannot be resolved
sun.io -- Cannot be resolved
sun.misc -- Cannot be resolved
sun.rmi.rmic -- Cannot be resolved
sun.security.action -- Cannot be resolved
sun.security.ec -- Cannot be resolved
sun.security.internal.interfaces -- Cannot be resolved
...
我查看了 这篇关于使用内部 sun 的文章类但它只引用javac。我的 Maven 构建开始如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<artifactId>cdncache</artifactId>
<packaging>bundle</packaging>
<name>NCDN Cache</name>
<description>Classes and interfaces to expire resource from the Akamai CDN cache [build:${build.number}]\
</description>
<version>1.0-${build.number}</version>
<properties>
<!-- Skip tests, so maven execution is faster. -->
<maven.test.skip>true</maven.test.skip>
<file.encoding>utf-8</file.encoding>
</properties>
<build>
<plugins>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.nymag.akamai,
com.akamai.*,
...
</Export-Package>
<Private-Package>
org.apache.axis.*,
...
sun.security,
sun.security.ec,
</Private-Package>
<Bundle-Version>1.0</Bundle-Version>
<Bundle-Activator>com.nymag.akamai.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
...
What options do I need to add to the maven build or the java runtime to access the internal sun.security classes? There is Java code from Akamai in an OSGI bundle needs access to internal sun.security classes. The Apache Felix console gives errors for the OSGI bundle:
sun.awt.image.codec -- Cannot be resolved
sun.io -- Cannot be resolved
sun.misc -- Cannot be resolved
sun.rmi.rmic -- Cannot be resolved
sun.security.action -- Cannot be resolved
sun.security.ec -- Cannot be resolved
sun.security.internal.interfaces -- Cannot be resolved
...
I looked at this article about using internal sun classes but it only refers to javac. My maven build starts like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<artifactId>cdncache</artifactId>
<packaging>bundle</packaging>
<name>NCDN Cache</name>
<description>Classes and interfaces to expire resource from the Akamai CDN cache [build:${build.number}]\
</description>
<version>1.0-${build.number}</version>
<properties>
<!-- Skip tests, so maven execution is faster. -->
<maven.test.skip>true</maven.test.skip>
<file.encoding>utf-8</file.encoding>
</properties>
<build>
<plugins>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.nymag.akamai,
com.akamai.*,
...
</Export-Package>
<Private-Package>
org.apache.axis.*,
...
sun.security,
sun.security.ec,
</Private-Package>
<Bundle-Version>1.0</Bundle-Version>
<Bundle-Activator>com.nymag.akamai.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意 stjohnroe 的观点,即使用特定于 VM 的类通常不好,但有时您必须这样做(例如,因为您当前处于过渡阶段)。如果您想这样做,可以添加
到框架属性中。如果您使用标准 Felix 启动器,您可以为此编辑
conf/config.properties
。I agree with stjohnroe that using VM-specific classes is usually bad, but sometimes you have to (for instance, as you are currently in a transition phase). If you want to do so, you can add
to the framework properties. If you use the standard Felix launcher, you can edit
conf/config.properties
for that.所有这些都是非公共 API 类,不能依赖于所有 jre 发行版中都存在。我相信它们都是现有的 sun 发行版,但不在 IBM 发行版等中。尝试在 Sun 发行版上运行,但这看起来像是针对未记录的功能进行构建的情况,这是一个很大的禁忌。
All of these are non public API classes and cannot be relied upon to be present in all jre distributions. I believe that they are all present sun distributions, but not in IBM distributions etc. Try running against a Sun distribution, but this looks like a case of building against undocumented features, a big no no.