This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git


The following commit(s) were added to refs/heads/main by this push:
     new 44e275590 Add -Yfuture-lazy-vals for Scala 3 builds (#1060)
44e275590 is described below

commit 44e2755900fe94bf7a477adf3b5d049d6765f746
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sat Jun 13 21:46:02 2026 +0800

    Add -Yfuture-lazy-vals for Scala 3 builds (#1060)
    
    * 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
    
    * Add MiMa filters for Scala 3 <clinit> 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
    <clinit> 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 <clinit> 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
    
    * 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
---
 .../scala3-future-lazy-vals-clinit.excludes        | 24 ++++++++++++++++++++++
 project/Common.scala                               |  4 +++-
 2 files changed, 27 insertions(+), 1 deletion(-)

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 000000000..005b8a430
--- /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 <clinit> 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.<clinit>")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.server.PathMatchers.<clinit>")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.server.directives.PathDirectives.<clinit>")
diff --git a/project/Common.scala b/project/Common.scala
index ce7270438..8558bc9fa 100644
--- a/project/Common.scala
+++ b/project/Common.scala
@@ -34,7 +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(
+      "-Wconf:cat=deprecation:s",
+      "-Yfuture-lazy-vals")).value,
     javacOptions ++=
       Seq("-encoding", "UTF-8", "--release", javacTarget),
     mimaReportSignatureProblems := true,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to