OpenHFT / Zero-Allocation-Hashing

Zero-allocation hashing for Java
Apache License 2.0
787 stars 136 forks source link

Make import to internal sun classes and the annotations optional #86

Open laeubi opened 8 months ago

laeubi commented 8 months ago

the sun.* classes are internal depending on the jvm settings especially the 'sun.nio.ch', this currently makes the lib unusable in its provided form without special configuration.

As the sun.nio.ch is actually optional (it is only used after instanceof checks) it could be marked optional import in the manifest so it is sued whenever the jvm provides the package and otherwise will not be used at all.

Also the annotations import is actually optional as the code does not reference it anywhere except as an annotation on methods/classes so the absence will just make the annotations invisible on runtime if not provided.

Beside that, it is actually a split package and therefore needs to mention the bundle it wants to import the package from.

This changes all sun.* packages to optional as well as the javax.annotation package and additionally mentions the bundle it wants to import the annotations from.

The (shortened) resulting manifest looks like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: OpenHFT :: zero-allocation-hashing
Bundle-SymbolicName: net.openhft.zero-allocation-hashing
Bundle-Version: 0.17.0.SNAPSHOT
Export-Package: net.openhft.hashing;uses:="javax.annotation";version="0.17.0.SNAPSHOT"
Import-Package: javax.annotation;resolution:=optional;bundle-symbolic-name="org.jsr-305";version="[3.0,4)",
 sun.misc;resolution:=optional,
 sun.nio.ch;resolution:=optional
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
laeubi commented 8 months ago

Build fails with

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar (default-cli) on project zero-allocation-hashing: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator

laeubi commented 7 months ago

@peter-lawrey-admin can you probably review/merge this?