The Scala 3.8.0 release shipped with a bug causing NoSuchFieldError exceptions at runtime, traced to invalid references to private fields in specialized standard library classes copied from Scala 2.13. The bug stemmed from the JVM Bytecode Optimizer inlining private field references differently than Scala 3 compiles them. A hotfix landed in 3.8.1, and both versions were announced together with guidance to upgrade directly to 3.8.1. The core team detailed the timeline, root causes (missing JUnit test porting, a two-month gap before discovery despite a long RC period), the fix (skipping bytecode optimization on copied class files and building them within the compiler repo), and new dedicated tests to prevent recurrence.
Table of contents
The TL;DRRecommendationsTimelineWhat exactly happened?ExamplesHow was this fixed?Why did it happen?How do we stop it from repeating?Further readingQuestions this post answers
Why does Scala 3.8.0 throw NoSuchFieldError at runtime for things like Range.grouped or ArrayOps.reverseIterator?
Scala 3.8.0's standard library copied .class files for @specialized members from the Scala 2.13 build that had been processed by the JVM Bytecode Optimizer, which inlines direct references to private fields such as private[this] val _empty. Those inlined references use a qualified name that differs under Scala 3 compilation, causing NoSuchFieldError. It affects a limited set of specialized collection methods and is fixed in 3.8.1. Track JVM compatibility bugs like this Scala 3.8.0 issue by following daily.dev for language ecosystem updates.
Should I upgrade to Scala 3.8.0 or skip straight to 3.8.1?
Upgrade directly to Scala 3.8.1, or 3.8.2 once available, and avoid 3.8.0. Scala 3.8.0 contains a bug where specialized standard library methods throw NoSuchFieldError at runtime due to invalid private field references, though the compiler does not flag it. Libraries already compiled and published with 3.8.0 are not corrupted and remain safe to use. Developers planning a Scala upgrade can follow release advisories like this on daily.dev before rolling out.
How was the Scala 3.8.0 NoSuchFieldError bug fixed in 3.8.1?
The fix stopped running the JVM Bytecode Optimizer on the copied .class files for @specialized standard library members, and those Scala 2 library class files are now built within the Scala 3 compiler repository for full control over their production. This resolved the mismatch in private field references that caused runtime NoSuchFieldError exceptions in 3.8.0. Engineers debugging toolchain regressions can follow fixes like this Scala 3.8.1 patch on daily.dev.