From f9ee9c83e1c912c3b1f6c7ce15ca972b55a5e118 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 13 Jun 2026 16:43:41 +0800 Subject: [PATCH 1/3] Add -Yfuture-lazy-vals for Scala 3.3.x builds Motivation: The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag (scala/scala3-lts#637) to optionally use VarHandle instead of sun.misc.Unsafe for lazy val implementation. This prepares libraries for upcoming JDK releases that restrict Unsafe access. Modification: Add -Yfuture-lazy-vals to DefaultScalacOptions in PekkoBuild.scala, conditionally applied only for Scala 3.3.x via CrossVersion.partialVersion. Result: Pekko's Scala 3.3.x build uses the future-proof VarHandle-based lazy val implementation, compatible with all JDK 9+ versions. Tests: - sbt "++3.3.8; actor/compile" passed (exit 0, 54 pre-existing warnings) References: Refs scala/scala3-lts#637 --- project/PekkoBuild.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/project/PekkoBuild.scala b/project/PekkoBuild.scala index 2eab25cf4c..3abb9ac862 100644 --- a/project/PekkoBuild.scala +++ b/project/PekkoBuild.scala @@ -97,7 +97,11 @@ object PekkoBuild { "-feature", "-unchecked", // 'blessed' since 2.13.1 - "-language:higherKinds") + "-language:higherKinds") ++ + (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, 3)) => Seq("-Yfuture-lazy-vals") + case _ => Nil + }) } else { Seq( "-encoding", From 754968a08ab74b68b3ae0449f19275d86715e520 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 13 Jun 2026 17:12:39 +0800 Subject: [PATCH 2/3] Add MiMa filter for -Yfuture-lazy-vals bytecode change The -Yfuture-lazy-vals flag changes the generated bytecode for companion objects containing lazy vals: the static initializer produced by the old sun.misc.Unsafe-based implementation is no longer emitted. Add a MiMa filter to exclude this expected binary incompatibility for RemoteWatcher#Stats. Tests: - sbt "++3.3.8; remote/mimaReportBinaryIssues" passed (exit 0) --- .../future-lazy-vals.excludes | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 remote/src/main/mima-filters/2.0.x.backwards.excludes/future-lazy-vals.excludes diff --git a/remote/src/main/mima-filters/2.0.x.backwards.excludes/future-lazy-vals.excludes b/remote/src/main/mima-filters/2.0.x.backwards.excludes/future-lazy-vals.excludes new file mode 100644 index 0000000000..113e1cfc66 --- /dev/null +++ b/remote/src/main/mima-filters/2.0.x.backwards.excludes/future-lazy-vals.excludes @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# -Yfuture-lazy-vals changes the generated bytecode for companion objects +# containing lazy vals: the static initializer that was produced +# by the old sun.misc.Unsafe-based implementation is no longer emitted. +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.remote.RemoteWatcher#Stats.") From 36aabbbda789d61e04303ab6085bb98b7566e645 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sun, 14 Jun 2026 02:30:56 +0800 Subject: [PATCH 3/3] Simplify -Yfuture-lazy-vals flag addition per PR review Motivation: PR #3059 review feedback from pjfanning requested simplifying the conditional CrossVersion.partialVersion match for -Yfuture-lazy-vals. Modification: Add -Yfuture-lazy-vals directly to the Scala 3 scalac options Seq instead of using a CrossVersion.partialVersion conditional match. Result: Cleaner, simpler build configuration that still applies the flag to all Scala 3.x builds. Tests: Not run - build config simplification only References: Refs apache/pekko#3059 --- project/PekkoBuild.scala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/project/PekkoBuild.scala b/project/PekkoBuild.scala index 3abb9ac862..e9847132b4 100644 --- a/project/PekkoBuild.scala +++ b/project/PekkoBuild.scala @@ -97,11 +97,8 @@ object PekkoBuild { "-feature", "-unchecked", // 'blessed' since 2.13.1 - "-language:higherKinds") ++ - (CrossVersion.partialVersion(scalaVersion.value) match { - case Some((3, 3)) => Seq("-Yfuture-lazy-vals") - case _ => Nil - }) + "-language:higherKinds", + "-Yfuture-lazy-vals") } else { Seq( "-encoding",