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

Add Module Support for OkHttp to Improve Compatibility with jlink and Java 9+ Modules #8588

Open
boheastill opened this issue Nov 23, 2024 · 1 comment
Labels
enhancement Feature not a bug

Comments

@boheastill
Copy link

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:

  1. Add module-info.java:
    Include a module-info.java file 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)
}

  1. 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 the jlink build tool.

  2. 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!

@boheastill boheastill added the enhancement Feature not a bug label Nov 23, 2024
@yschimke
Copy link
Collaborator

yschimke commented Nov 23, 2024

OkHttp added Automatic-Module-Name entries quite a while ago. And hopefully the overlapping modules are now split out.

https://github.com/square/okhttp/pull/3743/files

If I understand correctly, this is a limitation of jlink with such dependencies?

I think we previously pushed back on full support as it was expected to be quite disruptive for both development and builds.

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

No branches or pull requests

2 participants