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

osgi.ee computation needs to take modules-info.class into account #5334

Closed
laeubi opened this issue Jul 27, 2022 · 3 comments
Closed

osgi.ee computation needs to take modules-info.class into account #5334

laeubi opened this issue Jul 27, 2022 · 3 comments

Comments

@laeubi
Copy link
Contributor

laeubi commented Jul 27, 2022

I noticed when working on the multirelease support that when I have a jar file analyzed that is all java-8 with the exception of the modules-info.class then BND generates the following header

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

while I would expect it to be:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"

@rotty3000
Copy link
Contributor

There can be multiple module-info.class files in a multi-release jar. Meanwhile all the code in the jar is compiled to Java 8 which is still a perfectly valid jar and very much a valid use case.

What you might want is a META-INF/versions/x/MANIFEST.MF for each multi-release version which contains a Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=X))" targeting that exact version and ensure that the framework handles/merges Require-Capability.

@laeubi
Copy link
Contributor Author

laeubi commented Aug 2, 2022

There can be multiple module-info.class files in a multi-release jar. Meanwhile all the code in the jar is compiled to Java 8 which is still a perfectly valid jar and very much a valid use case.

This is independent of multi-release, you can try that out with a plan jar where all classes are compiled with java 8 and the module-info.class is compiled with java 9

What you might want is a META-INF/versions/x/MANIFEST.MF for each multi-release version which contains a Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=X))" targeting that exact version and ensure that the framework handles/merges Require-Capability.

Yes see #5331, still BND then generates for the version/9 part Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

@bjhargrave
Copy link
Member

bjhargrave commented Sep 6, 2022

osgi.ee computation must not take into account module-info.class. OSGi (consumer of osgi.ee) and JPMS (consumer of module-info.class) are mutually exclusive. While a jar can be built which is both a proper JPMS module and a proper OSGi bundle, the jar cannot be simultaneously loaded by both OSGi and JPMS.

In the OSGi case, module-info.class is ignored by OSGi bundle class loaders. So the class version of module-info.class is not material to OSGi.

In the JPMS case, osgi.ee is ignored by JPMS. So the osgi.ee version is not material to JPMS.

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

No branches or pull requests

3 participants