开发者

How to access the internal sun.security class from an OSGI bundle?

开发者 https://www.devze.com 2023-01-31 03:32 出处:网络
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

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>
    &l开发者_如何学编程t;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>
  ...


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

org.osgi.framework.system.packages.extra=sun.your.package.of.choice

to the framework properties. If you use the standard Felix launcher, you can edit conf/config.properties for that.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消