Repository navigation
Description
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
jira-importer commentedon Oct 3, 2026
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.
jira-importer commentedon Oct 4, 2026
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:
-sourceand-target, rather than-release.hc.build.toolchain.version, e.g../mvnw -Dhc.build.toolchain.version=21.)jdk.net.ExtendedSocketOptions.In theory, approach
#2means 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-releaseflag doesn't even exist on JDK8.) So if that option has already been disabled, then there isn't necessarily any further action required here.jira-importer commentedon Oct 4, 2026
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.netfrom 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