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

Provide module-info descriptor for java 9 and later #157

Open
daniel-jasinski opened this issue Nov 16, 2023 · 7 comments · May be fixed by #175
Open

Provide module-info descriptor for java 9 and later #157

daniel-jasinski opened this issue Nov 16, 2023 · 7 comments · May be fixed by #175
Labels

Comments

@daniel-jasinski
Copy link

daniel-jasinski commented Nov 16, 2023

It would be great if this library was provided as a multi-release jar with module-info.class descriptor, so that it could be part of the Java module system.

@Sporking
Copy link

Yes, please do this!

@qurbonzoda
Copy link
Contributor

Hi @daniel-jasinski,
To better understand the specific use cases and motivations behind this feature request, we would greatly appreciate it if you could provide us with more details.

  • What specific scenarios or projects would benefit from the integration of kotlinx.collections.immutable into the Java module system?
  • Are there any challenges or limitations you've encountered that this feature would help address?

Your insights will be invaluable in guiding our decision-making process and ensuring that any enhancements align closely with the needs of our user community.

@daniel-jasinski
Copy link
Author

Hi,
We are developing a desktop application with Compose-Multiplatform UI.
The app is packaged using JDK jpackage utility, and would like to make the app modular using JMS for various build hygiene and performance reasons. It would simplify our process if we did not have to do workarounds for some of our non-modular dependencies.

@sgammon
Copy link

sgammon commented Feb 23, 2024

@qurbonzoda The development experience without a module descriptor can be quite frustrating, for example, in IDEA:

Screenshot 2024-02-23 at 12 10 33 AM

But, from Gradle:

> Task :protocol:compileJava FAILED
/.../module-info.java:9: error: module not found: kotlinx.collections.immutable.jvm
  requires kotlinx.collections.immutable.jvm;

This is probably either originating from a Automatic-Module-Name, or from a generated module name from somewhere in IntelliJ. I'm not sure where, but the suggestion is wrong, and if I don't add the incorrect requires ... line, the code flags as an error in the IDE.

What specific scenarios or projects would benefit from the integration of kotlinx.collections.immutable into the Java module system?

Any scenario where the developer is using KotlinX Immutable Collections and wishes to distribute or package their own library or application with JPMS. Without the module descriptor in this library, the author has these choices:

  • Build with the library on the classpath. This defeats the optimizations and security guarantees provided by the module system, and is how the library works now.

  • Patch the module to make it an automatic module. This is done by adding Automatic-Module-Name to the JAR manifest for kotlinx-collections-immutable; it's not very easy to do this in build tools, and is suboptimal anyway, even if it was included in the JAR, because automatic modules can read the classpath, which (again) unfortunately defeats the optimizations and security guarantees provided by the module system.

  • Stop using the library. Because there is no alternative, the user has the hard choice to ditch JPMS entirely or this library, and ultimately, if the user has bought into JPMS already, the cost here is very high compared to just not using this code.

This is, unfortunately, the JPMS hand dealt to all of us by Oracle. Because of all the reasons above, KotlinX Serialization builds with a module-info, as do coroutines, datetime, and atomicfu. Thus, a user adding the full suite of KotlinX libraries may be in for a surprising and frustrating realization when this library does not provide one.

Edit: For anyone running into this issue in IDEs, you can suppress with:

@Suppress("JAVA_MODULE_DOES_NOT_DEPEND_ON_MODULE")

@qurbonzoda
Copy link
Contributor

@sgammon, thank you for your elaborate answer. We will aim to include module-info in our upcoming releases.

@qwwdfsad
Copy link
Member

@sgammon sgammon linked a pull request Mar 1, 2024 that will close this issue
@sgammon
Copy link

sgammon commented Mar 1, 2024

@qwwdfsad / cc @qurbonzoda I've posted a PR which uses Java9Modularity to ship a module-info. Let me know if you need any changes or have other review notes.

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

Successfully merging a pull request may close this issue.

5 participants