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

Manual: Add section about Resolving Multi-Release JAR Files #6135

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

chrisrueger
Copy link
Contributor

@chrisrueger chrisrueger commented May 28, 2024

Based on and almost quote of answer by @juergen-albert in https://bnd.discourse.group/t/questions-about-resolving-errors/450/3

I found your answer very good and thought this should be in the manual.
Open for feedback or additions.

Signed-off-by: Christoph <chrisrueger@gmail.com>
@chrisrueger chrisrueger changed the title Add section about Resolving Multi-Release JAR Files Manual: Add section about Resolving Multi-Release JAR Files May 28, 2024
Signed-off-by: Christoph <chrisrueger@gmail.com>
@juergen-albert
Copy link
Contributor

LGTM. I'd suggest @pkriens takes a final look, as he wrote most of the code around it.

@pkriens
Copy link
Member

pkriens commented Jun 6, 2024

This is not completely correct. There is only one bundle resource. This was a discussion when we developed the multi release jar support. @timothyjward wanted to model it as different bundles.

A Multi-Release JAR (MRJ) has directories in META-INF/versions/<release>. When the JAR is deployed on a VM with a given release R, that VM will preferentially load file resource from its own release R and then down to the main area. This means that a JAR can have different content depending on the VM it is deployed. For OSGi, this means that a bundle resource can have different requirements based on the runtime VM. The capabilities are the same since the public API must not change.

The problem is that this makes some requirements dependent on the VM. To model this, we introduced synthetic resource for each supported VM release that can only resolve on that release and when the release specific requirements of the bundle can be resolved.

This is only about modeling a JAR as a resource in an OSGi repository. Nothing is changed in the original JAR.

So we first treat the multi release bundle as any other bundle when we turn it into a resource, the release directories are ignored. If there are none, we're actually done.

Otherwise, we add a single requirement to a bnd.multirelease capability unique for this bundle. This namespace only has the properties bnd.multirelease=<bsn> and version=<version>. By requiring another resource, we can generate a synthetic resource for each VM release that the bundle supports. This is depicted here, where mrj is bnd.multirelease.

image

For the osgi.identity capability, we have to create a resource name that is unique. To keep it readable, the name is the original bsn + "__" + release. The version is the original bundle's version. We introduced a new type for these synthetic resources: bnd.synthetic.

We also add the requirements of the bundle if it would run on that release.

The synthetic resources are added to the same repository of the original bundle.

@rotty3000
Copy link
Contributor

rotty3000 commented Jun 6, 2024

I might be misunderstanding the image @pkriens, but are the versions in the green boxes flipped; where:

  • v17 -> J2SE [17, ~)
  • v8 -> J2SE [1.8, 17)

?

Aside from that, great explanation!

@pkriens
Copy link
Member

pkriens commented Jun 6, 2024

You're right. Will fix it.

Signed-off-by: Christoph <chrisrueger@gmail.com>
@chrisrueger
Copy link
Contributor Author

thanks @pkriens I have taken your answer and updated the text. see 4589c54 and added my example and the image.
Feel free to adjust this as needed. I feel that it could need an additional summary like sentence which nails it for a 5-year old but I am not capable of producing this sentence :)

image

I asked ChatGPT to summarize what you have written, but it basically repeated the same what you said, just structured a little bit different.

@pkriens
Copy link
Member

pkriens commented Jun 7, 2024

LGTM, go ahead and merge.

It is really hard to explain this stuff because in my mind it is so obvious, logical, and simple :-)

@chrisrueger
Copy link
Contributor Author

@pkriens any idea why the DCO failed? I have signed off as usual.

@pkriens
Copy link
Member

pkriens commented Jun 7, 2024

Commit sha: 4589c54, Author: Christoph Rueger, Committer: Christoph Rueger; Expected "Christoph Rueger chrisrueger@gmail.com", but got "Christoph chrisrueger@gmail.com".

Not sure what it means but I guess you can fix it? Otherwise just merge it .... if it happens again we can fix it.

@chrisrueger chrisrueger merged commit bbf85f4 into master Jun 7, 2024
2 of 3 checks passed
@chrisrueger chrisrueger deleted the chrisrueger-MRJ-resolve branch June 7, 2024 11:47
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.

4 participants