Using ScalaTest with Scala 3.8.1 and Java 25 LTS triggers a deprecation warning regarding the use of sun.misc.Unsafe. The current workaround is to pass the --sun-misc-unsafe-memory-access=allow to the JVM. However, this won’t last forever (see JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal).
The project doesn’t seem very active (the last release was a year and a half ago) and I don’t want to be caught off guard if ScalaTest suddenly becomes unusable. I rely heavily on it for testing and grading in several courses I teach.
Anyone knows what the plan is? Is ScalaTest dying? What’s the replacement? MUnit?
The problem with lazy vals and inactive libraries or their older versions would be fixed by tooling soon.
It shows to you directly via ScalaTest, but there might have been more dependencies compiled using old lazy-vals and using sun.misc.unsafe. It simply reports it once on the first occurrence, which when executing the tests seems to be ScalaTest, it’s not the only one.
We are working on tools to modify existing lazy-vals-related code to make them future-proof and ease migration to upcoming JDK versions. For more details, see the technical discussion in Jakub Kozłowski’s podcast with Łukasz Biały, VirtusLab’s Scala Advocate who prototyped this idea.
I’ve heard from Lukasz it’s already pretty advanced and behaves well in tests. We’d be running additional tests on the full Scala 3 ecosystem soon via Scala 3 Open Community Build to validate it and polish remaining rough edges as well as auditing it with the Scala 3 compiler team.
In the draft of JDK 26 changelog there is nothing about chaning the allowance of --sun-misc-unsafe-memory-access so it seems to be delayed now, and allowed some additional time, but we still need to prepare these changes based on their guidelines in JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
Is there an open ticket in the ScalaTest repo about the warnings?
For many libraries, no releases in 1.5 years might be a sign of trouble, but ScalaTest is such a mature project that it may simply be that there hasn’t been a need.
In ScalaTest we do not use sun.misc.Uns afe , when I launched sbt in ScalaTest I see these:
cheeseng@cheeseng-RAVEN:~/git/artima/scalatest$ sbt
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by net.openhft.hashing.UnsafeAccess (file:/home/cheeseng/.sbt/boot/scala-2.12.20/org.scala-sbt/sbt/1.11.7/zero-allocation-hashing-0.16.jar)
WARNING: Please consider reporting this to the maintainers of class net.openhft.hashing.UnsafeAccess
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.sun.jna.Native in an unnamed module (file:/home/cheeseng/.sbt/boot/scala-2.12.20/org.scala-sbt/sbt/1.11.7/jna-5.12.0.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
From the path is seems like they are from SBT’s boot classpath, I tried updated to the latest SBT 1.12.3 but seems to have same problem also.