Because someone will use Scala 2.13 on Java 25 too.
AFAIR Scala 2.13 never used the “bad” thing from sun.misc.unsafe - only Scala 3 used it, and only because people complained that lazy vals were slow on Scala 2.13 and that couldn’t be changed in a backward compatible way. So Scala 2.13 will not move to VarHandle because it uses something that would still work on Java 25+.
1 Like
Exactly as Mateusz explain, Scala 2 never used sun.misc.unsafe - it was a dedicated performance/thread-safety optimization introduced in Scala 3.
If you’re seeing warnings about sun.misc.Unsafe under Scala 2 then either it’s caused by some third-party dependencies (including Scala 3 libraries consumed by Scala 2) or build tool
2 Likes