From a94db0317c2e0c7fca36697678e9d742f8d76fe9 Mon Sep 17 00:00:00 2001 From: sstone Date: Thu, 17 Oct 2024 19:32:56 +0200 Subject: [PATCH] Target Java 21 Eclair now targets Java 21 and will require a compatible Java Runtime Environment. It will no longer work on JRE 11 and JRE 17. --- .github/workflows/latest-bitcoind.yml | 4 ++-- README.md | 2 +- docs/release-notes/eclair-vnext.md | 4 ++++ .../acinq/eclair/wire/protocol/LightningMessageTypes.scala | 6 +++++- eclair-node/src/main/scala/fr/acinq/eclair/Plugin.scala | 5 ++--- pom.xml | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/latest-bitcoind.yml b/.github/workflows/latest-bitcoind.yml index 26ea8ad60c..3ad462e1f1 100644 --- a/.github/workflows/latest-bitcoind.yml +++ b/.github/workflows/latest-bitcoind.yml @@ -38,10 +38,10 @@ jobs: with: path: eclair - - name: Set up JDK 11 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 21 distribution: 'adopt' - name: Configure OS settings diff --git a/README.md b/README.md index b9d531fb60..d6dae00fad 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ rpcclienttimeout=30 Eclair is developed in [Scala](https://www.scala-lang.org/), a powerful functional language that runs on the JVM, and is packaged as a ZIP archive. -To run Eclair, you first need to install Java. Eclair targets Java 11 and will run on any compatible Java runtime (including 11, 17 and 21), we recommend that you use [OpenJDK 21](https://adoptium.net/temurin/releases/?package=jdk&version=21). +To run Eclair, you first need to install Java. Eclair targets Java 21 and will run on any compatible Java runtime, we recommend that you use [OpenJDK 21](https://adoptium.net/temurin/releases/?package=jdk&version=21). Then download our latest [release](https://github.com/ACINQ/eclair/releases), unzip the archive and run the following command: diff --git a/docs/release-notes/eclair-vnext.md b/docs/release-notes/eclair-vnext.md index cc7ba22d9f..7a139285af 100644 --- a/docs/release-notes/eclair-vnext.md +++ b/docs/release-notes/eclair-vnext.md @@ -6,6 +6,10 @@ +### Eclair requires a Java 21 runtime + +Eclair now targets Java 21 and requires a compatible Java Runtime Environment. It will no longer work on JRE 11 or JRE 17. + ### API changes diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LightningMessageTypes.scala b/eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LightningMessageTypes.scala index 40cc0633c1..b73a67905e 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LightningMessageTypes.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LightningMessageTypes.scala @@ -491,7 +491,11 @@ object NodeAddress { } object IPAddress { - def apply(inetAddress: InetAddress, port: Int): IPAddress = inetAddress match { + def apply(inetAddress: InetAddress, port: Int): IPAddress = (inetAddress: @unchecked) match { + // we need the @unchecked annotation to suppress a "matching not exhaustive". Before JDK21, InetAddress was a regular so scalac would not check anything (it only checks sealed patterns) + // with JDK21 InetAddress is defined as `public sealed class InetAddress implements Serializable permits Inet4Address, Inet6Address` and scalac complains because in theory there could be + // an InetAddress() instance, though its not possible in practice because the constructor is package private :( + // remove @unchecked if we upgrade to a newer JDK that does not have this pb, or if scalac pattern matching becomes more clever case address: Inet4Address => IPv4(address, port) case address: Inet6Address => IPv6(address, port) } diff --git a/eclair-node/src/main/scala/fr/acinq/eclair/Plugin.scala b/eclair-node/src/main/scala/fr/acinq/eclair/Plugin.scala index d7e4100434..2cc9cffd20 100644 --- a/eclair-node/src/main/scala/fr/acinq/eclair/Plugin.scala +++ b/eclair-node/src/main/scala/fr/acinq/eclair/Plugin.scala @@ -17,8 +17,7 @@ package fr.acinq.eclair import java.io.File -import java.net.{JarURLConnection, URL, URLClassLoader} - +import java.net.{JarURLConnection, URI, URL, URLClassLoader} import akka.http.scaladsl.server.Route import fr.acinq.eclair.api.directives.EclairDirectives import grizzled.slf4j.Logging @@ -59,7 +58,7 @@ object Plugin extends Logging { } def openJar(jar: File): Option[JarURLConnection] = - Try(new URL(s"jar:file:${jar.getCanonicalPath}!/").openConnection().asInstanceOf[JarURLConnection]) match { + Try(URI.create(s"jar:file:${jar.getCanonicalPath}!/").toURL.openConnection().asInstanceOf[JarURLConnection]) match { case Success(url) => Some(url) case Failure(t) => logger.error(s"unable to load plugin file:${jar.getAbsolutePath} ", t); None } diff --git a/pom.xml b/pom.xml index 15d4c2745c..7cac4c3725 100644 --- a/pom.xml +++ b/pom.xml @@ -65,8 +65,7 @@ 2020-01-01T00:00:00Z UTF-8 - 11 - 11 + 21 2.13.11 2.13 2.6.20 @@ -151,6 +150,7 @@ -Werror -unchecked -deprecation + -release:21 -Xmx1024m