You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it's under the 9+ section of the mrjar. That's fine, but I wonder if we'd be better off getting modular-style Javadoc output, as we might if we moved it to the root? (Such output might either help or hurt people who are trying to link to us. Maybe it is part of the story with maxcellent/javadoc.io#182, but I haven't tried to understand that....)
If the only reason to care is Javadoc, we might also be able to just run Javadoc differently.
My feeling has been that this isn't too important. But if it changes the URLs of our Javadoc output, then we might want to do it sooner rather than later (or decide to never do it, which may or may not be swimming upstream). Or we could insert our own redirects from the old locations to the new at any point.
I have discovered an extremely trivial reason to put module-info in the root: It makes --describe-module slightly easier to use (but kudos to it for the helpful error message!):
$ jar --describe-module --file j2objc-annotations-3.0.0.jar
releases: 9
No root module descriptor, specify --release
$ jar --describe-module --file j2objc-annotations-3.0.0.jar --release 9
releases: 9
[email protected] jar:file:///tmp/jobjc_release.SF8NzIp/j2objc/annotations/target/j2objc-annotations-3.0.0.jar/!META-INF/versions/9/module-info.class open
exports com.google.j2objc.annotations
requires java.base
Presumably the original command would Just Work if the module-info were in the root.
Anyway, I don't think that should have much effect on a decision here. I'm still not sure if either way is significantly better than the other.
I just came across #245 (comment) again, which suggests that the Gradle "release" setting might not fully behavior like javac's --release flag, at least when the APIs differ across versions? We concluded there that we should just make the APIs not differ across versions. So the question now would be whether putting module-info under the Java 9 mrjar root counts as an "API difference" for that purpose. (Or we could still flip the question around and ask why not to put the module-info under the main root. If we're concerned about Javadoc (as discussed above), we can always run Javadoc ourselves when we want to, as discussed in #527 (comment).)
@cpovirk@kevinb9n Since you guys are talking about module-info and placement another consideration besides META-INF/releases is that module-info has the version of javac used to compile it (at least with maven)! When I say version I mean including patch version.
So if you compile a module-info with javac 17.0.11 the module-info will have 17.0.11 embedded init.
I'm not sure if Gradle has fixed that but I believe it is a problem even with the JDK but has been fixed in 22 and I believe Maven.
To fix it for my case I force the build to use an exact version of javac for reproducibility. The other option is to strip the info of which I'm not sure what tools are out there that do that especially gradle wise.
Anyway sorry if I wasted time if you guys already know this.
My JPMS module uses JSpecify.
I get the following warning every time I build my Javadoc (which links to JSpecify's Javadoc):
warning: The code being documented uses modules but the packages defined in https://jspecify.dev/docs/api/ are in the unnamed module.
Interesting, thanks. Are you able to link to the project or share a smaller project that reproduces the warning? Alternatively, have you been able to confirm that moving the module info resolves the warning?
I hacked up a local JSpecify build to put module-info in the root, and I pointed minipack at that, but I still see the warning.
I wonder if it could be caused by something about the way that Gradle is running the Javadoc tool. Unfortunately, that's far outside the areas of my expertise :(
Err, not that that command works for me at head, on account of:
src/main/java/org/jspecify/annotations/NullMarked.java:31: error: reference not found
* javax.lang.model.element.Element#getEnclosedElements() enclosed} within it are <b>null-marked
^
src/main/java/org/jspecify/annotations/NullUnmarked.java:30: error: reference not found
* javax.lang.model.element.Element#getEnclosedElements() enclosed} within it is <b>null-unmarked
^
Wait, no, sorry, it does work at head, but it does not work with my hacked-up changes! Those changes include not only a root module-info but also a change of sourceCompatibility and targetCompatibility to 9. So presumably we need to do something like that to get Gradle and/or javadoc into a sort of "modules mode." (Presumably we can adjust the settings for the Javadoc run but not the main build.) Then (well, after we fix the javax.lang.model.element issue) we'd get the modular Javadoc output that you're looking for (element-list: module:org.jspecify, org.jspecify.annotations). That includes changing the URL schema, breaking any links. I'm not sure there's a way to avoid that anymore, but we could set up redirects.
That is more than I am going to bite off now, but I'm glad to understand it better. Thanks for the report and the correction earlier. I've filed #712 to keep track of this. I suspect it's independent of where the module-info ends up in the jar, but we'll see.
[edit: And avoiding multi-release jars might be nice in general because of occasional other incomplete support for them, if I'm reading PIsberg/nanometer#17 right.]
From a specification point-of-view, doesn't a JAR file require all classes to be compiled under the same JDK version, and classes compiled by a different JDK version to be placed under META-INF/versions? Consider that line items in META-INF/MANIFEST.MF make that assumption.
You should absolutely be able to compile your code using one JDK version and your Javadoc using a different one. I've had to do something similar for some of my projects due to bugs in older versions of the javadoc tool.
So to recap: can't you compile your base classes using JDK 8, your module-info.java class using JDK 9+, and your Javadoc using JDK 25? That sounds like the safest route to me.
Sorry, I think I lost track of the new comment here because I applied my GMail star to an earlier post in the thread, thus burying it under newer starred items.
As far as I know, Java doesn't have any requirement that all classes in a jar (aside from META-INF/versions) use the same class-file version or are compiled by the same JDK version.
I do see that our MANIFEST.MF files have lines like this:
Gemini tells me that this is a way of saying "only allow this bundle to start on Java 8 or higher," so it likewise doesn't sound like a limitation on the class-file version or compile JDK. But I know even less here.
I think we're currently running Javadoc from JDK 24 (which yeah, I should bump to 25) and building with various JDK versions with different -source+-target / --release values for different parts of the build (main build, module-info build). I think that's all generally working OK. We could use older JDKs instead of -source+-target / --release, but I like to nudge people toward building with newer JDKs for the same kinds of reasons as you mention for nudging people toward generating Javadoc with newer JDKs. Of course, that has risks when we use -source+-target, but there's no getting around that when we want to use @Target(MODULE, ...) but still mostly work for users who target Java 8.
It's still possible that something could be improved, including that we should be putting module-info in the root. (I wonder if that affects whether Gradle and/or Maven automatically uses "modules mode" when it runs tests? All else being equal, we'd probably prefer to trigger "modules mode" in at least our own tests, even if it sometimes requires tweaks to those tests.)
As a side-note: JUnit 5's multi-release artifacts ship with module-info.classes in their modular JAR file roots since version 5.5.0 (June 30, 2019) although base classes target Java 8. We never received any issue reports in that regard.
The JUnit 5 precedent @sormuras mentioned is the clearest signal here — JUnit 5 has shipped module-info in the jar root since 5.5.0 (June 2019) with base classes targeting Java 8 and has received zero related issues. The Gradle mrjar build configuration JUnit uses (sourceSets.create("java9") compiled with --release 9, then merged into the main jar's root) is well-documented and avoids the Maven module-info version embedding issue that @agentgt flagged in jvm-repo-rebuild/reproducible-central#113.
For JSpecify specifically, moving module-info to the root would resolve at minimum:
The jar --describe-module inconvenience (--release flag required)
Cases like the smbj issue where tools misunderstand multi-release jar layering
The risk of downstream breakage from root module-info is minimal for a library like JSpecify that declares requires java.base only — consumers targeting Java 8 simply ignore module-info.class if their runtime doesn't understand it. The mrjar.gradle file already separates compilation, so the change would be moving the output destination from META-INF/versions/9/ to the jar root rather than changing the compilation target.
Since you guys are talking about module-info and placement another consideration besides META-INF/releases is that module-info has the version of javac used to compile it (at least with maven)! When I say version I mean including patch version.
So if you compile a module-info with javac 17.0.11 the module-info will have 17.0.11 embedded init.
I'm not sure if Gradle has fixed that but I believe it is a problem even with the JDK but has been fixed in 22 and I believe Maven.
While going over things with a fine-tooth comb in light of #867, I noticed that (besides the intentional addition of the JSpecify version for #746), we've picked up a "9" (the new "#11" value below), apparently in our requires java.base line. (I hadn't noticed because it isn't reported by jar --describe-module):
Based on my description, Gemini suggest this is the compiledVersion().
The value of 9 seems reasonable (and probably mostly inconsequential to begin with, at least as long as it's predictable!): It's the --release value that we pass, and we do so because it's (obviously) the lowest version to support modules.
Activity
cpovirk commentedon Feb 23, 2024
If the only reason to care is Javadoc, we might also be able to just run Javadoc differently.
My feeling has been that this isn't too important. But if it changes the URLs of our Javadoc output, then we might want to do it sooner rather than later (or decide to never do it, which may or may not be swimming upstream). Or we could insert our own redirects from the old locations to the new at any point.
cpovirk commentedon Mar 8, 2024
I have discovered an extremely trivial reason to put
module-infoin the root: It makes--describe-moduleslightly easier to use (but kudos to it for the helpful error message!):Presumably the original command would Just Work if the
module-infowere in the root.Anyway, I don't think that should have much effect on a decision here. I'm still not sure if either way is significantly better than the other.
cpovirk commentedon Jun 17, 2024
I just came across #245 (comment) again, which suggests that the Gradle "release" setting might not fully behavior like javac's
--releaseflag, at least when the APIs differ across versions? We concluded there that we should just make the APIs not differ across versions. So the question now would be whether puttingmodule-infounder the Java 9 mrjar root counts as an "API difference" for that purpose. (Or we could still flip the question around and ask why not to put themodule-infounder the main root. If we're concerned about Javadoc (as discussed above), we can always run Javadoc ourselves when we want to, as discussed in #527 (comment).)agentgt commentedon Jun 17, 2024
@cpovirk @kevinb9n Since you guys are talking about module-info and placement another consideration besides
META-INF/releasesis thatmodule-infohas the version of javac used to compile it (at least with maven)! When I say version I mean including patch version.So if you compile a
module-infowith javac17.0.11the module-info will have17.0.11embedded init.jvm-repo-rebuild/reproducible-central#113
I'm not sure if Gradle has fixed that but I believe it is a problem even with the JDK but has been fixed in 22 and I believe Maven.
To fix it for my case I force the build to use an exact version of javac for reproducibility. The other option is to strip the info of which I'm not sure what tools are out there that do that especially gradle wise.
Anyway sorry if I wasted time if you guys already know this.
odenix commentedon Nov 27, 2024
My JPMS module uses JSpecify.
I get the following warning every time I build my Javadoc (which links to JSpecify's Javadoc):
cpovirk commentedon Nov 27, 2024
Interesting, thanks. Are you able to link to the project or share a smaller project that reproduces the warning? Alternatively, have you been able to confirm that moving the module info resolves the warning?
odenix commentedon Nov 27, 2024
Reproducer:
(In case you wondered, I just open-sourced this project.)
cpovirk commentedon Nov 27, 2024
Thanks!
I hacked up a local JSpecify build to put
module-infoin the root, and I pointed minipack at that, but I still see the warning.I wonder if it could be caused by something about the way that Gradle is running the Javadoc tool. Unfortunately, that's far outside the areas of my expertise :(
odenix commentedon Nov 27, 2024
Did you change minipack's
javadoctask to point to your locally built javadoc?https://github.com/translatenix/minipack/blob/main/minipack-core/build.gradle.kts#L56
cpovirk commentedon Nov 27, 2024
Nope, sorry about that! Let me see....
cpovirk commentedon Nov 27, 2024
Note to self: To actually build Javadoc successfully, you need to set the
JAVA_VERSIONenvironment variable, as in:cpovirk commentedon Nov 27, 2024
Err, not that that command works for me at head, on account of:
But it apparently works fine in GitHub Actions, as shown by the working Javadoc at https://jspecify.dev/docs/api/org/jspecify/annotations/NullMarked.html. I'm going to try with an actual release of 23.
cpovirk commentedon Nov 27, 2024
Wait, no, sorry, it does work at head, but it does not work with my hacked-up changes! Those changes include not only a root
module-infobut also a change ofsourceCompatibilityandtargetCompatibilityto 9. So presumably we need to do something like that to get Gradle and/or javadoc into a sort of "modules mode." (Presumably we can adjust the settings for the Javadoc run but not the main build.) Then (well, after we fix thejavax.lang.model.elementissue) we'd get the modular Javadoc output that you're looking for (element-list:module:org.jspecify,org.jspecify.annotations). That includes changing the URL schema, breaking any links. I'm not sure there's a way to avoid that anymore, but we could set up redirects.That is more than I am going to bite off now, but I'm glad to understand it better. Thanks for the report and the correction earlier. I've filed #712 to keep track of this. I suspect it's independent of where the
module-infoends up in the jar, but we'll see.odenix commentedon Nov 27, 2024
Thanks for filing #712.
FYI, to temporarily suppress Javadoc errors, add this line to your
build.gradle:1 remaining item
cpovirk commentedon Apr 21, 2025
It seems believable (but far from guaranteed) that a root-directory
module-infowould have avoided the problem in hierynomus/smbj#865 [edit: and https://github.com/bebsworthy/pocket_agent/commit/3b2d71559e723231241484c93da29d2763b9e168 and customerio/customerio-flutter#304 and CybotTM/kidsync@6e93fc7 and bmander/thecityandthebike@1364625 and Loken75/password-manager@31601fb and liekzejaws/rushlight#2 and CallMeTechie/OriDev#161 and dappros/ethora-sdk-android@a965cdb + dappros/ethora-sdk-android@d120f91 and kiloiam/BiliPai-Article@d5a51ef and SaadRimeh/SaloumApp@45b99a7 and nganlinh4/screen-goated-toolbox@824e146 and szerzogabor/mesha#284 and IvoryCobra-VC/lidseeker#37 and 1c-syntax/intellij-language-1c-bsl@3180367 and https://github.com/AbakoDolla/SXB-VPN/commit/61e3c1b6b2a90e7859098f70a955f640790afcfb and https://github.com/workingfivetonine/TimetoPayApp/commit/1ea6aaeee158ac972822438655774b862cd6a52c and boxcreate/boxlore@fc04500#diff-cd364d6c7d2884761543189df41b262b804d4cb5c61b4e8f35f9656892420267R48 and Metalrott420/intermingled-@16dcce9 and likely convivae/SystemUI-Gradle@0766a30#diff-967f76ee7cddd1107a40f46aedd0911a39e3ac782daaeb542f09c67c3361491fR44 and https://github.com/Anon5T4R/LocalKeysAndroid/commit/6936056af3aca38f6b900b2c5c17382f686aab9e and https://github.com/kaelen-phoenix/yo-boot/commit/500b20d1b7116dbe74284d29dbea278e27b0ba8d and markmtm/synccast@d315258 and dimxyp/openssh-android@a67da0b and xnexgamerx-byte/Social-Hub44@b22a3d7 and maragung/EclipseSSH@0b3cb3d and ReSerendipity/DraftPeek@c290948 and Gooseberry111/Between-Us@3e5dc6a, too]: Perhaps some tool understands that it may see multiple "versions" ofMETA-INF/MANIFEST.MFbut notMETA-INF/versions/9/OSGI-INF/MANIFEST.MF, and we could eliminate the latter by not having an additional root? But I'm guessing here. (And even if I'm right, the ideal solution would be for the tool to be fixed.)[edit: and how about the OSGi part of google/error-prone#4971?]
[edit: And avoiding multi-release jars might be nice in general because of occasional other incomplete support for them, if I'm reading PIsberg/nanometer#17 right.]
cowwoc commentedon Sep 21, 2025
Maybe I've missed something but...
META-INF/versions? Consider that line items inMETA-INF/MANIFEST.MFmake that assumption.javadoctool.So to recap: can't you compile your base classes using JDK 8, your
module-info.javaclass using JDK 9+, and your Javadoc using JDK 25? That sounds like the safest route to me.cpovirk commentedon Oct 2, 2025
Sorry, I think I lost track of the new comment here because I applied my GMail star to an earlier post in the thread, thus burying it under newer starred items.
As far as I know, Java doesn't have any requirement that all classes in a jar (aside from
META-INF/versions) use the same class-file version or are compiled by the same JDK version.I do see that our
MANIFEST.MFfiles have lines like this:Gemini tells me that this is a way of saying "only allow this bundle to start on Java 8 or higher," so it likewise doesn't sound like a limitation on the class-file version or compile JDK. But I know even less here.
I think we're currently running Javadoc from JDK 24 (which yeah, I should bump to 25) and building with various JDK versions with different
-source+-target/--releasevalues for different parts of the build (main build,module-infobuild). I think that's all generally working OK. We could use older JDKs instead of-source+-target/--release, but I like to nudge people toward building with newer JDKs for the same kinds of reasons as you mention for nudging people toward generating Javadoc with newer JDKs. Of course, that has risks when we use-source+-target, but there's no getting around that when we want to use@Target(MODULE, ...)but still mostly work for users who target Java 8.It's still possible that something could be improved, including that we should be putting
module-infoin the root. (I wonder if that affects whether Gradle and/or Maven automatically uses "modules mode" when it runs tests? All else being equal, we'd probably prefer to trigger "modules mode" in at least our own tests, even if it sometimes requires tweaks to those tests.)Build docs with JDK 25.
Build docs with JDK 25. (#774)
cpovirk commentedon Apr 28, 2026
I wonder if this change was working around our current
module-infosetup:sparrowlogic/whisper4j@9c3f31a
sormuras commentedon Jun 10, 2026
As a side-note: JUnit 5's multi-release artifacts ship with
module-info.classes in their modular JAR file roots since version 5.5.0 (June 30, 2019) although base classes target Java 8. We never received any issue reports in that regard.cschanhniem commentedon Jun 18, 2026
The JUnit 5 precedent @sormuras mentioned is the clearest signal here — JUnit 5 has shipped
module-infoin the jar root since 5.5.0 (June 2019) with base classes targeting Java 8 and has received zero related issues. The Gradle mrjar build configuration JUnit uses (sourceSets.create("java9")compiled with--release 9, then merged into the main jar's root) is well-documented and avoids the Mavenmodule-infoversion embedding issue that @agentgt flagged in jvm-repo-rebuild/reproducible-central#113.For JSpecify specifically, moving
module-infoto the root would resolve at minimum:jar --describe-moduleinconvenience (--releaseflag required)smbjissue where tools misunderstand multi-release jar layeringThe risk of downstream breakage from root
module-infois minimal for a library like JSpecify that declaresrequires java.baseonly — consumers targeting Java 8 simply ignoremodule-info.classif their runtime doesn't understand it. Themrjar.gradlefile already separates compilation, so the change would be moving the output destination fromMETA-INF/versions/9/to the jar root rather than changing the compilation target.Place `module-info` in the root of the jar. (jspecify#809)
cpovirk commentedon Aug 5, 2026
While going over things with a fine-tooth comb in light of #867, I noticed that (besides the intentional addition of the JSpecify version for #746), we've picked up a "9" (the new "#11" value below), apparently in our
requires java.baseline. (I hadn't noticed because it isn't reported byjar --describe-module):Based on my description, Gemini suggest this is the
compiledVersion().The value of 9 seems reasonable (and probably mostly inconsequential to begin with, at least as long as it's predictable!): It's the
--releasevalue that we pass, and we do so because it's (obviously) the lowest version to support modules.This is another reason to be happy that we force a specific, new version of javac so that we benefit from the mentioned fix. (And it might be another reason to be happy to probably not have a strict need to further touch our build system much at the moment.)
Place `module-info` in the root of the jar.
Place `module-info` in the root of the jar.