From 2b526b327fa5bc797e7ccb169e07bd132660a584 Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Tue, 17 Dec 2024 12:53:39 +1100 Subject: [PATCH] Enforce `-release` 8 base compilation target (#2250) Set -release 8 base compilation target Restructured the compile phases in the POM so that when executing on Java 9+, the base classes are compiled with -release 8. This ensures that the bootstrap class path uses the Java 8 API, and so the produced jar is binary compat with Java 8. When built on Java 8, the original source and target (vs release) are used. Fixes an issue where when running on Java 8 (but built on Java9+), `java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;` would be thrown in ControllableInputStream buffering up, because the return expected `Buffer`, not the binary incompatible `ByteBuffer`. --- CHANGES.md | 3 +++ pom.xml | 59 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2d832a807d..c394a82b95 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,9 @@ "name". [2241](https://github.com/jhy/jsoup/issues/2241) * In `Connection`, skip cookies that have no name, rather than throwing a validation exception. [2242](https://github.com/jhy/jsoup/issues/2242) +* When running on JDK 1.8, the error `java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;` + could be thrown when parsing from a URL and the buffer size was + exceeded. [2250](https://github.com/jhy/jsoup/pull/2250) ## 1.18.3 (2024-Dec-02) diff --git a/pom.xml b/pom.xml index a2731952e5..5c6716b1b1 100644 --- a/pom.xml +++ b/pom.xml @@ -38,29 +38,27 @@ - org.apache.maven.plugins maven-compiler-plugin 3.13.0 UTF-8 + false - -Xpkginfo:always - - false + - compile-java-8 - - 1.8 - 1.8 - + default-compile + none + + + default-testCompile + none - @@ -83,7 +81,6 @@ 1.0 - java.nio.ByteBuffer java.net.HttpURLConnection @@ -292,7 +289,7 @@ org.jsoup.UncheckedIOException - org.jsoup.nodes.Element + org.jsoup.nodes.Element @@ -345,6 +342,36 @@ + + + java-8 + + 1.8 + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + compile + compile + + compile + testCompile + + + 1.8 + 1.8 + + + + + + + + compile-multi-release @@ -357,12 +384,19 @@ org.apache.maven.plugins maven-compiler-plugin + compile-java-8 + compile + + compile + testCompile + 8 + compile-java-9 compile @@ -377,6 +411,7 @@ true +