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

Add 'uses' information to OSGI metadata in MANIFEST.MF #1492

Closed
wants to merge 2 commits into from

Conversation

sratz
Copy link
Contributor

@sratz sratz commented Dec 19, 2022

When multiple versions of JNA are present in a single OSGI environment, it can happen that OSGI computes an incorrect dependency chain, which can lead to exceptions like the following:

This can be addressed by enriching the Export-Package metadata with ;uses="..." information [1].

Fixes #1487.

[1] https://spring.io/blog/2008/10/20/understanding-the-osgi-uses-directive/

@matthiasblaesing
Copy link
Member

Thank you for the PR.

I have one question: Were the uses build by you manually or did you use bnd or some other tool? In any case it would be good if you could add a comment how the useses clauses were created, so that in the future this can be reproduced and updated.

Were you able to test this change in your target environment to ensure, that it really works?

A side comment: I suggest to to move all JNA usages to 5.X. 5.X is mostly a cleanup release, that removed terminally broken methods or thing being deprecated since a long time.

When multiple versions of JNA are present in a single OSGI environment,
it can happen that OSGI computes an incorrect dependency chain, which
can lead to exceptions like the following:

This can be addressed by enriching the Export-Package metadata with
;uses="..." information [1].

Fixes java-native-access#1487.

[1] https://spring.io/blog/2008/10/20/understanding-the-osgi-uses-directive/
@sratz
Copy link
Contributor Author

sratz commented Dec 22, 2022

Were the uses build by you manually or did you use bnd or some other tool? In any case it would be good if you could add a comment how the useses clauses were created, so that in the future this can be reproduced and updated.

To be honest, it was a bit of a manual mess. :)

Typically, if a regular maven build was used, one would simply let org.apache.felix:maven-bundle-plugin do the heavy lifting:
https://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html

I am not really familiar with JNA's ant-based build system.

I have now tried to create something reproducible: In the 2nd commit I created a small utility shell script. It

  • spawns maven to compile the sources and creates a dummy MANIFEST.MF using org.apache.felix:maven-bundle-plugin
  • extracts the relevant instruction from the dummy MANIFEST.MF, and post-processes it to be copy-pasted into build.xml.

This is quite a hack, but should provide the necessary information in a reproducible way. Maybe this is a good starting point to this more directly in the build process?

Were you able to test this change in your target environment to ensure, that it really works?

Yes, I tested the latest version 5.12.1 with adjusted metadata in our product and it works well.

@matthiasblaesing
Copy link
Member

@sratz could you please have a look at #1494. I added this commit: 1af6eb1

  • osgi.version was used in primary build.xml, not defined. This lead to the property call showing up in the MANIFEST.mf
  • a comment referencing the shell script was added
  • the shell script was wrapped to improve readability
  • an entry for the CHANGES.md file was added

If you agree, I would merge your changes via that PR.

@sratz
Copy link
Contributor Author

sratz commented Jan 9, 2023

@matthiasblaesing Looks good! Thanks for cleaning up the remaining issues. I'm closing this PR in favor of #1494

@sratz sratz closed this Jan 9, 2023
@sratz sratz deleted the osgi-uses branch January 9, 2023 08:30
@matthiasblaesing
Copy link
Member

@sratz thanks for checking. JNA 5.13.0 was release with your updates.

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.

OSGI metadata in MANIFEST.MF is missing 'uses:' information
2 participants