Add -Yfuture-lazy-vals for Scala 3 builds#1060
Merged
Merged
Conversation
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
Member
|
mima issues |
Motivation: The -Yfuture-lazy-vals flag added in 6d25f5e 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#1060
pjfanning
reviewed
Jun 13, 2026
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#1060
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The Scala 3.3.8 compiler introduced the
-Yfuture-lazy-valsflag (scala/scala3-lts#637) to optionally useVarHandleinstead ofsun.misc.Unsafefor lazy val implementation. This prepares libraries for upcoming JDK releases that restrictsun.misc.Unsafeaccess.Modification
Add
-Yfuture-lazy-valstoCommon.scalascalacOptions using the existingonlyOnScala3helper: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, only pre-existing warnings)References
Refs scala/scala3-lts#637