[WIP] Add sloth support#4348
Draft
Gedochao wants to merge 9 commits into
Draft
Conversation
Contributor
Author
|
@lbialy how close are we to publishing a stable version of |
Gedochao
force-pushed
the
feature/lazyvalgrade
branch
from
June 30, 2026 08:38
a8e0c42 to
52da2af
Compare
Contributor
|
Why is it called "lazyvalgrade", what does "grade" mean here? |
Contributor
Author
|
@SethTisue I believe that's a pun on "lazy val upgrade". |
Gedochao
force-pushed
the
feature/lazyvalgrade
branch
from
July 2, 2026 14:03
52da2af to
330d1d0
Compare
Contributor
Author
|
https://central.sonatype.com/search?q=org.virtuslab+sloth |
lbialy
reviewed
Jul 3, 2026
lbialy
reviewed
Jul 3, 2026
lbialy
reviewed
Jul 3, 2026
Member
|
Do we now have adopt a sloth in a zoo? And have sloth plushies? |
Contributor
Author
|
We should. 🦥 |
Gedochao
force-pushed
the
feature/lazyvalgrade
branch
2 times, most recently
from
July 14, 2026 10:19
bbac081 to
15645e2
Compare
Gedochao
force-pushed
the
feature/lazyvalgrade
branch
from
July 21, 2026 10:11
b243a04 to
714f8a5
Compare
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.
Adds Sloth support behind
--sloth///> using slothhttps://github.com/VirtusLab/sloth
Scala 3, up till 3.7.x series, has been using the (now terminally deprecated)
sun.misc.UnsafeAPI. This in turn results in some ugly warnings on JDK 24+ (and likely errors in the future).Now, while Scala 3.8+ uses a new implementation, and Scala 3.3 allows for the new implementation on JDK 9+ behind the
-Yfuture-lazy-valscompiler flag, the problem is not entirely solved. Even if your app is on the latest Scala, it likely still depends on libraries built with Scala 3.3 (or some other <3.8 version). That in turn brings the problem back. And since it is not widespread to suffix Scala 3 libraries with the minor, as we did in Scala 2 days, it is not entirely easy to spot which libraries will pose a problem.Sloth is a bytecode patcher, which is capable of patching all past lazy val implementations (including the pre-3.3 one) up to the current one. Kudos to @lbialy for developing it.
Behind the
--slothflag, this PR allows to post-process and patch the bytecode of your app/artifacts to silently get rid of the problem.The
--sloth-agentflag runs Sloth as a Java agent instead, allowing it to i.e. run in the JVM your tests live.More details on how it works and what it does at https://github.com/VirtusLab/sloth
This feature is brought to the following sub-commands:
Checklist
scala-cli fmt .)scalafix(./mill -i __.fix)./mill -i 'generate-reference-doc[]'.run)How much have your relied on LLM-based tools in this contribution?
extensively, Cursor + Claude
How was the solution tested?
./mill -i integration.test.jvm '*sun.misc.Unsafe*'