jira-importer opened a new issue, #1499:
URL: https://github.com/apache/httpcomponents-core/issues/1499

   **[Oleg 
Kalnichevski](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=olegk)**
 opened 
**[HTTPCORE-802](https://issues.apache.org/jira/browse/HTTPCORE-802?redirect=false)**
 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](https://issues.apache.org/jira/browse/HTTPCORE-802?redirect=false)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to