-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Title: Add Module Support for OkHttp to Improve Compatibility with jlink and Java 9+ Modules
Description:
I am currently working on a project using OkHttp (version 4.x / 5.0.0-alpha.14) and encountered an issue while trying to create a modular application in a Java 9+ environment using jlink. The problem stems from the fact that OkHttp does not declare its own module via a module-info.java file, which leads to compatibility issues with the Java Platform Module System (JPMS).
The absence of module declarations in OkHttp causes errors during jlink modular application creation, as OkHttp internally uses modules (such as okio), but it does not provide explicit module definitions, resulting in runtime conflicts and build failures.
Suggested Solution:
I recommend adding official module support to OkHttp as follows:
- Add
module-info.java:
Include amodule-info.javafile in the OkHttp repository, declaring the necessary modules. For example:
module okhttp {
requires java.net.http; // if OkHttp uses Java's HTTP-related API
requires okio; // OkHttp depends on Okio
exports okhttp3; // export the relevant packages (adjust based on OkHttp's internal structure)
}
-
Ensure Compatibility with JPMS:
Ensure that OkHttp works seamlessly with the Java Platform Module System (JPMS) and can function correctly in modular applications, especially when using thejlinkbuild tool. -
Provide a Version with Module Support:
If full module support cannot be achieved immediately, would it be possible to provide a clear roadmap or plan to help users understand the progress on module support and avoid issues when migrating to modular Java applications?
Background:
Currently, OkHttp does not declare any modules. While it works fine with JDK 8 and earlier versions, the lack of module support becomes problematic in Java 9+ environments, particularly when using jlink for creating custom Java runtimes. This issue is especially prominent because jlink requires all dependencies to have clear module declarations.
Expected Outcome:
By adding module support for OkHttp, developers will be able to:
- Avoid issues when building custom runtimes using
jlink. - Integrate OkHttp more easily into modular Java applications, improving compatibility with JDK 9+.
- Prevent runtime conflicts and improve overall performance for modular applications using OkHttp.
Thanks: Thank you for considering this request. I believe that adding module support for OkHttp will greatly improve its usability in modern modular Java applications.
This version is ready for submission. Let me know if you’d like to make any changes or need further adjustments!