|
| 1 | +--- |
| 2 | +category: announcement |
| 3 | +permalink: /news/next-scala-lts.html |
| 4 | +title: "Next Scala 3 LTS series will increase minimum required JDK version" |
| 5 | +by: Tomasz Godzik |
| 6 | +--- |
| 7 | + |
| 8 | +**TL;DR** |
| 9 | + |
| 10 | +The Scala 3 Next minors in 2025 Q4 and the next LTS will drop JDK 8 support. We |
| 11 | +are seeking feedback on whether the new minimum JDK should be 11 or 17. |
| 12 | + |
| 13 | +## Immediate motivation |
| 14 | + |
| 15 | +The memory-access methods in `sun.misc.Unsafe` are scheduled for removal in a |
| 16 | +future JDK, as stated in the recent [JEP 471](https://openjdk.org/jeps/471). |
| 17 | +Currently, Scala 3 uses `sun.misc.Unsafe` in its implementation of `lazy val`. |
| 18 | +In order to support JDK 25+, we will need to drop usage of `Unsafe`. We are |
| 19 | +investigating the required changes under |
| 20 | +[this issue](https://github.com/scala/scala3/issues/9013). |
| 21 | + |
| 22 | +It then started to dawn on the compiler team that we might consider dropping |
| 23 | +support for JDK 8 altogether in a future release of Scala 3. |
| 24 | + |
| 25 | +## Long term motivation |
| 26 | + |
| 27 | +Switching to a newer version of the JDK would allow both the compiler and the |
| 28 | +Scala ecosystem to start using new features and standard library improvements |
| 29 | +brought in by JDK 9+. This might include a number of JEPs (JDK Enhancement |
| 30 | +Proposals), which the compiler team will investigate during the coming year. To |
| 31 | +check the current status, take a look at the issues marked with the |
| 32 | +[JEP label](https://github.com/scala/scala3/issues?q=is%3Aissue+is%3Aopen+label%3Acompat%3Ajava%3Ajep). |
| 33 | + |
| 34 | +Some of the features that might be interesting to the Scala community are: |
| 35 | + |
| 36 | +- [JEP 181](https://github.com/scala/scala3/issues/22292) will allow classes |
| 37 | + that are logically connected, to access each other's private members. This |
| 38 | + could be useful for representing nested classes and companion objects. |
| 39 | + (Currently, the Scala compiler has to insert public bridge methods to broaden |
| 40 | + the accessibility of those members.) |
| 41 | +- [JEP 409](https://github.com/scala/scala3/issues/22298) introduces sealed |
| 42 | + classes. It would allow the compiler to better represent Scala's sealed trait |
| 43 | + hierarchies. |
| 44 | +- [JEP 441](https://github.com/scala/scala3/issues/22450) introduces new |
| 45 | + bytecode shapes for pattern matching in Java. With them, we may be able to |
| 46 | + optimize the code resulting from Scala pattern matches. |
| 47 | +- [JEP 471](https://github.com/scala/scala3/issues/9013) adds a new API for |
| 48 | + memory access. We will use it to replace the usage of `sun.misc.Unsafe` in |
| 49 | + Scala 3. |
| 50 | + |
| 51 | +Dropping JDK 8 will reduce the maintenance burden on tooling and library |
| 52 | +authors. They currently have to take into account a large number of different |
| 53 | +versions, both for correctness and performance. Thus, the benefits of this |
| 54 | +change will be felt ecosystem-wide. |
| 55 | + |
| 56 | +JDK 8 was first published in 2014, over 10 years ago. JDKs have advanced greatly |
| 57 | +since then. In order to stay competitive, using those advancements is a must. A |
| 58 | +lot of the existing distributions, including |
| 59 | +[Oracle's own](https://www.oracle.com/java/technologies/java-se-support-roadmap.html), |
| 60 | +have already stopped or will soon stop updating JDK 8 with security and other |
| 61 | +fixes. It is of course possible not to update your libraries and compiler |
| 62 | +version, to avoid having to switch to a newer JDK. However, that is highly |
| 63 | +discouraged, as it will make you vulnerable to potential security risks. |
| 64 | + |
| 65 | +Some larger projects in the Java and Scala ecosystems have already dropped JDK 8 |
| 66 | +support in favor of JDK 11 or even 17. |
| 67 | + |
| 68 | +Java examples include: |
| 69 | + |
| 70 | +- [Spring 6](https://spring.io/blog/2022/11/16/spring-framework-6-0-goes-ga) |
| 71 | + requires JDK 17 |
| 72 | +- [Hibernate](https://hibernate.org/orm/releases/6.6/) requires JDK 11 and the |
| 73 | + next version will require JDK 17 |
| 74 | +- [Jetty](https://jetty.org/docs/jetty/12/index.html) requires JDK 17 |
| 75 | +- [Logback](https://logback.qos.ch/dependencies.html) requires JDK 11 |
| 76 | +- [JavaFX](https://gluonhq.com/products/javafx/) requires JDK 21 |
| 77 | +- [Vaadin](https://github.com/vaadin/platform/releases/tag/24.6.0) requires JDK |
| 78 | + 17 |
| 79 | +- [Quarkus](https://quarkus.io/blog/quarkus-3-7-released/) requires JDK 17 |
| 80 | +- [TensorFlow](https://github.com/tensorflow/java) requires JDK 11 |
| 81 | + |
| 82 | +Scala examples include: |
| 83 | + |
| 84 | +- [Spark 4](https://github.com/apache/spark/pull/43005#issuecomment-1731344040) |
| 85 | + will require JDK 17 |
| 86 | +- [Play Framework](https://github.com/playframework/playframework/issues/11078) |
| 87 | + requires JDK 11 and |
| 88 | + [will require JDK 17](https://github.com/playframework/playframework/issues/12179) |
| 89 | + in the next major release |
| 90 | +- [Akka](https://github.com/akka/akka/pull/32127) requires JDK 11 |
| 91 | +- [Apache Kafka](https://kafka.apache.org/documentation/#java) requires JDK 11 |
| 92 | +- [ZIO](https://github.com/zio/zio/pull/8434) requires JDK 11 |
| 93 | +- [Li Haoyi's ecosystem](https://github.com/com-lihaoyi) requires JDK 11 across |
| 94 | + the board |
| 95 | + |
| 96 | +This shows that the rest of the industry is already moving away from JDK 8. |
| 97 | + |
| 98 | +## Plan for making the switch |
| 99 | + |
| 100 | +The current plan is to drop support of JDK 8 in one of the future minor releases |
| 101 | +of Scala 3 and in the next LTS. The new minimum JDK will be either 11 or 17, |
| 102 | +depending on the community feedback and our investigations. The current estimate |
| 103 | +for the next LTS is Q4 2025. |
| 104 | + |
| 105 | +One major challenge will be to preserve backward compatibility. As we change the |
| 106 | +encoding of `lazy val`s, we must still be able to use libraries compiled with |
| 107 | +earlier Scala 3 versions. |
| 108 | + |
| 109 | +## How does it affect me? |
| 110 | + |
| 111 | +The current line of LTS under 3.3.x will be supported for at least another year |
| 112 | +after the release of the next LTS version. That should give you plenty of time |
| 113 | +to migrate. After that, no more security fixes will be available for Scala 3 |
| 114 | +versions supporting JDK 8. |
| 115 | + |
| 116 | +If you are using Scala 3 on JDK 8, do let us know! If it is not possible for you |
| 117 | +to switch, be sure to send us your feedback so that we can figure out a way to |
| 118 | +help you migrate. |
| 119 | + |
| 120 | +## Discussions and further reading |
| 121 | + |
| 122 | +You can track the current work related to lazy values under |
| 123 | +[this issue](https://github.com/scala/scala3/issues/9013). |
| 124 | + |
| 125 | +Discussion on the topic of dropping JDK 8 support is available on the |
| 126 | +[Scala contributors forum](https://contributors.scala-lang.org/t/next-scala-3-lts-version-will-increase-minimum-required-jdk-version) |
0 commit comments