Skip to content

Add -Yfuture-lazy-vals for Scala 3.3.x builds#3059

Merged
He-Pin merged 3 commits into
apache:mainfrom
He-Pin:add-Yfuture-lazy-vals-scala3
Jun 14, 2026
Merged

Add -Yfuture-lazy-vals for Scala 3.3.x builds#3059
He-Pin merged 3 commits into
apache:mainfrom
He-Pin:add-Yfuture-lazy-vals-scala3

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 13, 2026

Copy link
Copy Markdown
Member

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 sun.misc.Unsafe access.

Modification

  • Add -Yfuture-lazy-vals to DefaultScalacOptions in project/PekkoBuild.scala, conditionally applied only for Scala 3.3.x via CrossVersion.partialVersion
  • Add MiMa filter in remote/src/main/mima-filters/2.0.x.backwards.excludes/future-lazy-vals.excludes to exclude the expected <clinit> bytecode change for RemoteWatcher#Stats (the new VarHandle-based lazy val implementation no longer generates the static initializer that the old Unsafe-based implementation produced)

Result

Pekko's Scala 3.3.x build uses the future-proof VarHandle-based lazy val implementation, compatible with all JDK 9+ versions including future releases that restrict sun.misc.Unsafe.

Tests

  • sbt "++3.3.8; actor/compile" — passed (exit 0, only pre-existing warnings)
  • sbt "++3.3.8; remote/mimaReportBinaryIssues" — passed (exit 0)

References

Refs scala/scala3-lts#637

He-Pin added 2 commits June 13, 2026 16:43
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
The -Yfuture-lazy-vals flag changes the generated bytecode for
companion objects containing lazy vals: the static <clinit>
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)
@He-Pin He-Pin requested a review from pjfanning June 13, 2026 10:19
Comment thread project/PekkoBuild.scala Outdated
@He-Pin He-Pin requested a review from pjfanning June 13, 2026 15:22
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jun 13, 2026
Motivation:
PR apache#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#3059
@He-Pin He-Pin requested review from Philippus and mdedetrich June 14, 2026 08:19

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit bf54798 into apache:main Jun 14, 2026
9 checks passed
@He-Pin He-Pin deleted the add-Yfuture-lazy-vals-scala3 branch June 14, 2026 09:41
He-Pin added a commit to apache/pekko-projection that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add -release:17 required by -Yfuture-lazy-vals

The -Yfuture-lazy-vals flag requires explicit -java-output-version
set to minimum version 9 or higher. Add -release:17 to satisfy
this requirement for Scala 3.3.x builds.
He-Pin added a commit to apache/pekko-persistence-cassandra that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add -release:17 required by -Yfuture-lazy-vals

The -Yfuture-lazy-vals flag requires explicit -java-output-version
set to minimum version 9 or higher. Add -release:17 to satisfy
this requirement for Scala 3.3.x builds.
He-Pin added a commit to apache/pekko-persistence-jdbc that referenced this pull request Jun 14, 2026
Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059
He-Pin added a commit to apache/pekko-persistence-r2dbc that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add -release:17 required by -Yfuture-lazy-vals

The -Yfuture-lazy-vals flag requires explicit -java-output-version
set to minimum version 9 or higher. Add -release:17 to satisfy
this requirement for Scala 3.3.x builds.
He-Pin added a commit to apache/pekko-connectors-kafka that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add -release:17 required by -Yfuture-lazy-vals

The -Yfuture-lazy-vals flag requires explicit -java-output-version
set to minimum version 9 or higher. Add -release:17 to satisfy
this requirement for Scala 3.3.x builds.
He-Pin added a commit to apache/pekko-management that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add MiMa filter for HttpBootstrapJsonProtocol <clinit>

-Yfuture-lazy-vals changes the generated bytecode for companion
objects containing lazy vals: the static <clinit> initializer
is no longer emitted. Add MiMa filter to exclude this expected
binary compatibility change.
He-Pin added a commit to apache/pekko-connectors that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add MiMa filters for <clinit> removed by -Yfuture-lazy-vals

-Yfuture-lazy-vals changes the generated bytecode for companion
objects containing lazy vals: the static <clinit> initializer
is no longer emitted. Add MiMa filters to exclude these expected
binary compatibility changes for:
- aws-spi-pekko-http: PekkoHttpClient
- google-cloud-bigquery: BigQueryJsonProtocol, BigQueryRestJsonProtocol
- google-cloud-pub-sub-grpc: ScalaPB-generated grpc objects

* fix: Add missing Handshaker* MiMa filters in google-cloud-pub-sub-grpc

Add 4 DirectMissingMethodProblem filters for HandshakerReq, HandshakerResp,
HandshakerResult, and HandshakerStatus companion object <clinit> methods
that are no longer generated with -Yfuture-lazy-vals.
He-Pin added a commit to apache/pekko-persistence-dynamodb that referenced this pull request Jun 14, 2026
* feat: Add -Yfuture-lazy-vals for Scala 3.3.x builds

Motivation:
The Scala 3.3.8 compiler introduced the -Yfuture-lazy-vals flag to
optionally use VarHandle instead of sun.misc.Unsafe for lazy val
implementation. This prepares libraries for upcoming JDK releases
that restrict sun.misc.Unsafe access.

Modification:
Add -Yfuture-lazy-vals to scalacOptions, conditionally applied only
for Scala 3.3.x via CrossVersion.partialVersion or scalaBinaryVersion.

Result:
Scala 3.3.x build uses the future-proof VarHandle-based lazy val
implementation, compatible with all JDK 9+ versions including future
releases that restrict sun.misc.Unsafe.

References:
Refs scala/scala3-lts#637
Refs apache/pekko#3059

* fix: Add -release:17 required by -Yfuture-lazy-vals

The -Yfuture-lazy-vals flag requires explicit -java-output-version
set to minimum version 9 or higher. Add -release:17 to satisfy
this requirement for Scala 3.3.x builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants