Skip to content

[HTTPCORE-802] Re-enable release target validation  #1499

Backlog

Description

@jira-importer

Oleg Kalnichevski opened HTTPCORE-802 and commented

jdk.net.ExtendedSocketOptions causes compatibility problems with newer JDKs when using Java 8 as a release target (--release compile option).

Newer JDKs fail to import jdk.net package when targeting Java 8 apparently due this feature being considered invalid for Java 8

$ mvn -v
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /home/oleg/opt/maven
Java version: 17.0.17, vendor: Amazon.com Inc., runtime: /home/oleg/opt/amazon-corretto-17.0.17.10.1
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.12.107+deb13-amd64", arch: "amd64", family: "unix"
$ mvn clean compile -P-use-toolchains -DjavaVersion=8
[INFO] --- compiler:3.16.0:compile (default-compile) @ httpcore5 ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 570 source files with javac [debug deprecation release 8] to target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java:[52,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java:[48,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java:[49,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpServer.java:[44,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpServer.java:[45,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequestListener.java:[41,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequestListener.java:[42,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/util/ReflectionUtils.java:[30,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/util/ReflectionUtils.java:[31,15] package jdk.net does not exist
[ERROR] /home/oleg/src/apache.org/httpcomponents/httpcore/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java:[334,41] cannot find symbol

When using the same JDK and targeting Java 11, the same code compiles successfully

mvn clean compile -P-use-toolchains -DjavaVersion=11
 
[INFO] --- compiler:3.16.0:compile (default-compile) @ httpcore5 ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 570 source files with javac [debug deprecation release 11] to target/classes
...
[INFO] Reactor Summary for Apache HttpComponents Core 5.5-beta4-SNAPSHOT:
[INFO] 
[INFO] Apache HttpComponents Core ......................... SUCCESS [  1.089 s]
[INFO] Apache HttpComponents Core HTTP/1.1 ................ SUCCESS [  9.346 s]
[INFO] 

I had to disable release target validation due to this problem when upgrading our maven POM. Please note the check was not used prior to the upgrade.

Given that the animal sniffer plugin has been discontinued in favor of JDK release target validation, we have lost a valuable quality control mechanism and a safe-guard. 

The best course of action would be just upgrade to Java 17 and forget about Java 8 compatibility woes.

Alternatively, we could consider removing direct import of jdk.net classes and go back to using reflection.

Oleg

 

 


No further details from HTTPCORE-802

Activity

  1. jira-importer commented on Oct 3, 2026

    @jira-importer
    CollaboratorAuthor

    Arturo Bernal commented

    I would prefer to keep Java 8 compatibility and isolate the JDK-specific socket options behind reflection.

    Raising the runtime baseline should be a separate decision, not a workaround for this issue.

  2. jira-importer commented on Oct 4, 2026

    @jira-importer
    CollaboratorAuthor

    Ryan Schmitt commented

    These compilation failures are caused by a bug in the JDK:

    https://bugs.openjdk.org/browse/JDK-8365060

    This doesn't make them any less annoying, but at least it's a straight answer to the question "why isn't this working?"

    There are a few options here:

    1. Cross-compile with -source and -target, rather than -release.
    2. Don't cross-compile. Use Maven toolchain support to both compile for and test on a particular Java version. (This is the option I went with when I reworked the build logic in March of this year, with the toolchain version controlled by hc.build.toolchain.version, e.g. ./mvnw -Dhc.build.toolchain.version=21.)
    3. Enable cross-compilation by using reflection to access jdk.net.ExtendedSocketOptions.

    In theory, approach #2 means that there's nothing to "validate," because we build for JDK8 by using an actual JDK8 toolchain, rather than cross-compilation from a newer JDK. (In fact, the -release flag doesn't even exist on JDK8.) So if that option has already been disabled, then there isn't necessarily any further action required here.

  3. jira-importer commented on Oct 4, 2026

    @jira-importer
    CollaboratorAuthor

    Oleg Kalnichevski commented

    Hi Ryan

    Unless I am mistaken but the option 1 ensures byte-code compatibility, not API / platform compatibility. So, it is not 

    Anyhow, given the omission of jdk.net from Java 8 profile was an oversight, let's wait and do nothing. It may still get fixed.

    I will restart the discussion regarding Java 8 compatibility after the HttpClient 5.7 GA release.

    Oleg  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions