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

Current release is compiled for Java 8 but requires Java 9 in bundle manifest #346

Open
martingd opened this issue Feb 2, 2022 · 7 comments

Comments

@martingd
Copy link

martingd commented Feb 2, 2022

The compiled jars available at

are compiled with class file format for Java 8 but the bundle manifest tells OSGi that Java 9 is required:

% cat META-INF/MANIFEST.MF | grep Require-Capability
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"

The consequence of this is that the jar does not work as a bundle with OSGi running on Java 8.

For comparison, the manifest for scala-parser-combinators says:

% cat META-INF/MANIFEST.MF | grep Require-Capability      
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

which is what I would expect also in this jar.

If possible I would be happy to assist fixing this issue but I am not sure where the build is configured.

@martingd martingd changed the title Current release is compiled for Java 9 and does not run with Java 8 Current release is compiled for Java 8 but requires Java 9 in bundle manifest Feb 2, 2022
@martingd
Copy link
Author

martingd commented Feb 3, 2022

@SethTisue I am aware this is a community project and neither you nor anybody else is the official maintainer. However, maybe you can point me in the right direction.

It seems this issue was introduced with the latest release. I have taken a look at all jars released to MVNRepository (https://mvnrepository.com/artifact/com.typesafe.scala-logging/scala-logging) back to 2018, and only in the latest release (3.9.4) the manifest states Java 9 is required when running in an OSGi context:
(See the last four jars in below listing.)

% find . -type f | gsed -E 's/(^.*-([0-9]+\.[0-9]+\.[0-9]+)\..*$)/\2#\1/g' | sort | cut -d# -f2 | xargs -n1 -I{} unzip -c {} META-INF/MANIFEST.MF | grep -E "^Archive|Require-Capability"
Archive:  ./scala-logging_2.11-3.8.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8.0_14
Archive:  ./scala-logging_2.12-3.8.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8.0_14
Archive:  ./scala-logging_2.13.0-M3-3.8.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8.0_14
Archive:  ./scala-logging_2.11-3.9.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.12-3.9.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13.0-M3-3.9.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13.0-M4-3.9.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13.0-M5-3.9.0.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13.0-M5-3.9.1.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.11-3.9.2.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.12-3.9.2.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13-3.9.2.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13.0-RC2-3.9.2.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13.0-RC3-3.9.2.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.11-3.9.3.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.12-3.9.3.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.13-3.9.3.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_3.0.0-RC1-3.9.3.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  ./scala-logging_2.11-3.9.4.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"
Archive:  ./scala-logging_2.12-3.9.4.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"
Archive:  ./scala-logging_2.13-3.9.4.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"
Archive:  ./scala-logging_3-3.9.4.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"

However, if I clone the repo to my own machine, checkout tag v3.9.4 and build locally, I get the correct result: Java 8 (1.8) is required for OSGi.

% find ~/.ivy2/local/com.typesafe.scala-logging | grep bundles | grep jar$ | gsed -E 's/(^.*-([0-9]+\.[0-9]+\.[0-9]+)\..*$)/\2#\1/g' | sort | cut -d# -f2 | xargs -n1 -I{} unzip -c {} META-INF/MANIFEST.MF | grep -E "^Archive|Require-Capability"
Archive:  /Users/mgd/.ivy2/local/com.typesafe.scala-logging/scala-logging_2.11/3.9.4/bundles/scala-logging_2.11.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  /Users/mgd/.ivy2/local/com.typesafe.scala-logging/scala-logging_2.12/3.9.4/bundles/scala-logging_2.12.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  /Users/mgd/.ivy2/local/com.typesafe.scala-logging/scala-logging_2.13/3.9.4/bundles/scala-logging_2.13.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Archive:  /Users/mgd/.ivy2/local/com.typesafe.scala-logging/scala-logging_3/3.9.4/bundles/scala-logging_3.jar
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

This points to some sort of build configuration not in the Git repo but in the setup of the build-system – and I don't really know where to look.

Hope you can help.

@SethTisue
Copy link
Collaborator

I wish I had some insight, but this isn't anything I've seen before.

@martingd
Copy link
Author

martingd commented Feb 3, 2022

I found a clue in the manifest.

Comparing the manifest for 3.9.3 with the one for 3.9.4 reveals that even though the code was compiled for a 1.8 target (with class file format 52), it seems an Oracle JDK 9 was used for building 3.9.4 wheres AdoptOpenJDK 8 (1.8.0_282) was used for building 3.9.3.

See this diff of the MANIFEST.MF files from 3.9.3 and 3.9.4 respctively:

% diff -U1 <(unzip -c scala-logging_3.0.0-RC1-3.9.3.jar META-INF/MANIFEST.MF) <(unzip -c scala-logging_3-3.9.4.jar META-INF/MANIFEST.MF)
--- /dev/fd/11	2022-02-04 00:13:08.000000000 +0100
+++ /dev/fd/12	2022-02-04 00:13:08.000000000 +0100
@@ -1,5 +1,5 @@
-Archive:  scala-logging_3.0.0-RC1-3.9.3.jar
+Archive:  scala-logging_3-3.9.4.jar
   inflating: META-INF/MANIFEST.MF    
 Manifest-Version: 1.0
-Bnd-LastModified: 1616508550301
+Bnd-LastModified: 1623846646435
 Bundle-Description: scala-logging
@@ -11,7 +11,7 @@
 Bundle-Vendor: com.typesafe.scala-logging
-Bundle-Version: 3.9.3
-Created-By: 1.8.0_282 (AdoptOpenJDK)
+Bundle-Version: 3.9.4
+Created-By: 9 (Oracle Corporation)
 Export-Package: com.typesafe.scalalogging;uses:="org.slf4j,scala.colle
  ction.immutable,scala.quoted,scala.reflect,scala.runtime";version="3.
- 9.3"
+ 9.4"
 Implementation-Title: scala-logging
@@ -20,3 +20,3 @@
 Implementation-Vendor-Id: com.typesafe.scala-logging
-Implementation-Version: 3.9.3
+Implementation-Version: 3.9.4
 Import-Package: org.slf4j;version="[1.7,2)",scala;version="[2.13,3)",s
@@ -25,6 +25,6 @@
  [2.13,3)",scala.runtime;version="[2.13,3)"
-Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
+Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"
 Specification-Title: scala-logging
 Specification-Vendor: com.typesafe.scala-logging
-Specification-Version: 3.9.3
+Specification-Version: 3.9.4
 Tool: Bnd-5.1.2.202007211702

Apart from bumping the version from 3.9.3 to 3.9.4, everything is the same (including the version of Bnd used to create the bundle manifest) except for these two notable differences:

-Created-By: 1.8.0_282 (AdoptOpenJDK)
+Created-By: 9 (Oracle Corporation)
...
-Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
+Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))"

So I am pretty sure, the issue is caused by using Java 9 for producing the released jars for 3.9.4.

@analytically Do you have an idea where and how the build is configured? If I can, I will happily help fixing this.

@SethTisue
Copy link
Collaborator

SethTisue commented Feb 3, 2022

https://github.com/lightbend/scala-logging/blob/main/.github/workflows/release.yml says Temurin 8, so I suspect the problem is already fixed for the next release. 3.9.4 was July 2021, but #299 didn't land until October 2021.

Perhaps Travis-CI was somehow misconfigured for 3.9.4, or perhaps the release was done from @analytically's own machine locally rather than through CI.

@martingd
Copy link
Author

martingd commented Feb 4, 2022

@SethTisue That sounds like a plausible explanation.
Let's keep this issue open and await the next release to see if it fixes the problem.

Thank you for helping.

@SethTisue
Copy link
Collaborator

about release timing: #407

@jxnu-liguobin
Copy link
Collaborator

@martingd Has 3.9.5 solved the problem?

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

No branches or pull requests

3 participants