mail-api icon indicating copy to clipboard operation
mail-api copied to clipboard

jakarta.mail-api is not a Multi Release JAR

Open aalmiray opened this issue 2 years ago • 5 comments

Describe the bug Latest jakarta.mail-api (2.1.1) includes 6 classes compiled to bytecode 53 and 148 classes to compiled to bytecode 52. All classes are found in the unversioned space which means enforcer rules for both Maven and Gradle will trigger and fail a build.

To Reproduce Steps to reproduce the behavior:

  1. Get jarviz
$ jarviz bytecode show --gav jakarta.mail:jakarta.mail-api:2.1.1 
Unversioned classes. Bytecode version: 52 total: 148
Unversioned classes. Bytecode version: 53 total: 6

If the --details flag is added you get the names of the 6 classes causing trouble

Unversioned classes. Bytecode version: 53 total: 6
jakarta.mail.search.package-info
jakarta.mail.util.package-info
jakarta.mail.event.package-info
jakarta.mail.internet.package-info
jakarta.mail.package-info
module-info

Expected behavior These 6 classes should be inside /META-INF/versions/9. The JAR's manifest should have a manifest entry such as Multi-Release: true

https://docs.oracle.com/javase/10/docs/specs/jar/jar.html#multi-release-jar-files

aalmiray avatar Feb 06 '23 18:02 aalmiray

It looks we have the same issue we had here, and I bet this is a problem in many other projects: https://github.com/eclipse-ee4j/parsson/issues/73

I will apply the same fix.

We don't need a multirelease, right?. package-info.java can be compiled with release 8 with no issues.

jbescos avatar Feb 08 '23 08:02 jbescos

What about module-info.class? It can neither be compiled nor ran with jdk/runtime 8. So the problem is only partially fixed with the package-info job?

Also, would (and could) this be ported over to 1.x? Asking because in need of multiline POP3 xoauth2 authentication, but, stuck to pre-jakarta mail (1.6.2) because of the classes compiled with 53 major version.

FredDietrich avatar Jun 28 '23 16:06 FredDietrich

This can be addressed here.

It looks we will not compile with JDK 8 anymore, everything will be compiled for JDK 9 or 11, and we don't need a multirelease for module-info.

jbescos avatar Feb 29 '24 10:02 jbescos

FWIW you would still need a multi-release JAR if classes compiled with multiple bytecode levels find their way into the JAR, as noted the enforcer plugins check compliance to a given level in the whole unversioned classes space.

This is not a Java 8 only thing.

aalmiray avatar Feb 29 '24 17:02 aalmiray

FWIW you would still need a multi-release JAR if classes compiled with multiple bytecode levels find their way into the JAR, as noted the enforcer plugins check compliance to a given level in the whole unversioned classes space.

This is not a Java 8 only thing.

The idea is to compile everything with JDK 11, so we will not need a multirelease jar.

jbescos avatar Mar 01 '24 05:03 jbescos