From 6d25f5ee8d289d3546016e3b009834e2397b0c90 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 13 Jun 2026 16:55:27 +0800 Subject: [PATCH 1/3] Add -Yfuture-lazy-vals for Scala 3 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 Common.scala scalacOptions using the existing onlyOnScala3 helper. Result: pekko-http's Scala 3 build uses the future-proof VarHandle-based lazy val implementation, compatible with all JDK 9+ versions. Tests: - sbt "++3.3.8; http/compile" passed (exit 0, 66s) References: Refs scala/scala3-lts#637 --- project/Common.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/project/Common.scala b/project/Common.scala index ce72704388..37ef3f3610 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -35,6 +35,7 @@ object Common extends AutoPlugin { // verbosely. So, opt out of those in general. "-Wconf:cat=other-match-analysis&msg=match may not be exhaustive:s")).value, scalacOptions ++= onlyOnScala3(Seq("-Wconf:cat=deprecation:s")).value, + scalacOptions ++= onlyOnScala3(Seq("-Yfuture-lazy-vals")).value, javacOptions ++= Seq("-encoding", "UTF-8", "--release", javacTarget), mimaReportSignatureProblems := true, From a65900cf36e1f991acdedd45c13b7f2d6aa6a55e Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 13 Jun 2026 19:27:21 +0800 Subject: [PATCH 2/3] Add MiMa filters for Scala 3 removals Motivation: The -Yfuture-lazy-vals flag added in 6d25f5ee8 changes the Scala 3 bytecode generated for object lazy vals. As a side effect, the synthetic static initializers on Directives, PathMatchers, and PathDirectives are no longer emitted, causing MiMa to flag three DirectMissingMethodProblem errors against the 1.0.0 baseline. These are compiler-internal initialization methods, not part of the public API, so the change is binary compatible in practice. Modification: Add a new mima-filters exclude file under 2.0.x.backwards.excludes/ to suppress the three missing-method warnings on the Scala 3 build. Result: sbt "++3.3.8; http/mimaReportBinaryIssues" and validatePullRequest MiMa checks pass again. References: Refs apache/pekko-http#1060 --- .../scala3-future-lazy-vals-clinit.excludes | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 http/src/main/mima-filters/2.0.x.backwards.excludes/scala3-future-lazy-vals-clinit.excludes diff --git a/http/src/main/mima-filters/2.0.x.backwards.excludes/scala3-future-lazy-vals-clinit.excludes b/http/src/main/mima-filters/2.0.x.backwards.excludes/scala3-future-lazy-vals-clinit.excludes new file mode 100644 index 0000000000..005b8a4303 --- /dev/null +++ b/http/src/main/mima-filters/2.0.x.backwards.excludes/scala3-future-lazy-vals-clinit.excludes @@ -0,0 +1,24 @@ +# 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. + +# Scala 3's -Yfuture-lazy-vals flag changes the bytecode generated for object +# lazy vals, removing the synthetic methods present in the 1.0.0 +# baseline. These are compiler-internal initialization methods and are not +# part of the public API, so the change is binary compatible in practice. +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.server.Directives.") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.server.PathMatchers.") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.server.directives.PathDirectives.") From bc82dac5a2119be141019cf3d5c0c191868c26b4 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 13 Jun 2026 21:18:38 +0800 Subject: [PATCH 3/3] fix: merge onlyOnScala3 scalacOptions into a single Seq Motivation: Code review requested combining the two onlyOnScala3 calls into one. Modification: Merge "-Wconf:cat=deprecation:s" and "-Yfuture-lazy-vals" into a single onlyOnScala3(Seq(...)) call. Result: Cleaner build definition with both Scala 3 options in one place. Tests: Not run - build config only References: Refs apache/pekko-http#1060 --- project/Common.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/Common.scala b/project/Common.scala index 37ef3f3610..8558bc9fa2 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -34,8 +34,9 @@ object Common extends AutoPlugin { // In all other cases, the warning is non-actionable: you get spurious warnings that need to be suppressed // verbosely. So, opt out of those in general. "-Wconf:cat=other-match-analysis&msg=match may not be exhaustive:s")).value, - scalacOptions ++= onlyOnScala3(Seq("-Wconf:cat=deprecation:s")).value, - scalacOptions ++= onlyOnScala3(Seq("-Yfuture-lazy-vals")).value, + scalacOptions ++= onlyOnScala3(Seq( + "-Wconf:cat=deprecation:s", + "-Yfuture-lazy-vals")).value, javacOptions ++= Seq("-encoding", "UTF-8", "--release", javacTarget), mimaReportSignatureProblems := true,