From 11e9d6bac6266ccc320a056c509fe3c03d2b917b Mon Sep 17 00:00:00 2001 From: Holger Friedrich Date: Tue, 14 May 2024 13:02:25 +0200 Subject: [PATCH] Support Java 21 (#1640) * Allow for compiling with Java 21 * Support Java 17 and 21, default compilation to Java 17 class files * Add profile "j21" to compile to Java 21 class files * Upgrade SAT to 0.16.0 * Adapt Karaf scpipts to allow both Java 17 and 21 Signed-off-by: Holger Friedrich --- .../openhab/src/main/resources/bin/karaf | 4 +++- .../openhab/src/main/resources/bin/karaf.bat | 6 ++++-- launch/app/pom.xml | 10 ++++++++-- pom.xml | 16 +++++++++++----- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/distributions/openhab/src/main/resources/bin/karaf b/distributions/openhab/src/main/resources/bin/karaf index 34c4f2f552..bc3a799280 100755 --- a/distributions/openhab/src/main/resources/bin/karaf +++ b/distributions/openhab/src/main/resources/bin/karaf @@ -160,7 +160,9 @@ init() { # Determine the JVM version and check that it is version 17 checkJvmVersion if [ "${VERSION}" -ne "17" ]; then - die "JVM must be version 17. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)" + if [ "${VERSION}" -ne "21" ]; then + die "JVM must be version 17 or 21. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)" + fi fi # Check if a root instance is already running diff --git a/distributions/openhab/src/main/resources/bin/karaf.bat b/distributions/openhab/src/main/resources/bin/karaf.bat index ae536d4d74..f9ccdc6f28 100644 --- a/distributions/openhab/src/main/resources/bin/karaf.bat +++ b/distributions/openhab/src/main/resources/bin/karaf.bat @@ -215,8 +215,10 @@ for /f tokens^=2-5^ delims^=.-_+^" %%j in ('"%JAVA%" -fullversion 2^>^&1') do ( ) if %JAVA_VERSION% NEQ 17 ( - call :warn "JVM must be version 17. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)" - goto END + if %JAVA_VERSION% NEQ 21 ( + call :warn "JVM must be version 17 or 21. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)" + goto END + ) ) if %JAVA_VERSION% GTR 8 ( diff --git a/launch/app/pom.xml b/launch/app/pom.xml index bd7b1a16cf..84042d24d0 100644 --- a/launch/app/pom.xml +++ b/launch/app/pom.xml @@ -15,8 +15,7 @@ UTF-8 UTF-8 17 - ${oh.java.version} - ${oh.java.version} + ${oh.java.version} 7.0.0 @@ -383,6 +382,13 @@ + + j21 + + 21 + ${oh.java.version} + + diff --git a/pom.xml b/pom.xml index 4bddab49ef..42e1c35283 100644 --- a/pom.xml +++ b/pom.xml @@ -64,10 +64,9 @@ 4.4.5 17 - ${oh.java.version} - ${oh.java.version} + ${oh.java.version} - 0.15.0 + 0.16.0 2.38.0 4.25 @@ -111,7 +110,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.13.0 org.apache.maven.plugins @@ -249,7 +248,7 @@ - [17.0,18.0) + [17.0,18.0),[21.0,22.0) @@ -319,6 +318,13 @@ + + j21 + + 21 + ${oh.java.version} + +