Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: ea
Choose a base branch
from

Conversation

laeubi
Copy link

@laeubi laeubi commented Jan 5, 2024

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))"

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.
@laeubi
Copy link
Author

laeubi commented Jan 5, 2024

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
Copy link
Author

laeubi commented Jan 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant