Year-end insights from the Minecraft to JDK 16 migration and Q&A with the Mojang team
The year is drawing to a close, whether we like it or not, and we look back to 2021. Among the things worth mentioning, especially in the Java world, is likely the release of JDK 17, the LTS version with features like Pattern matching for switches, a new Vector api or sealed classes. The release promises improved performance out of the box as Application and Class Data Sharing (AppCDS) is one of the new features along with the improved performance of the new G1 Garbage Collector. Although the release date was clearly set, the Minecraft team decided to make the switch earlier and migrate to JDK 16. This is all the more interesting since Minecraft is now part of Microsoft and therefore uses the newly developed JRE. Given their lead in running Java 16 in production, InfoQ spoke to the Mojang team to better understand their experience and benefits.
InfoQ: What was the reason for migrating to Java 16 when Java 17 was around the corner? Have you migrated to Java 17 or do you intend to? Which version did you migrate from?
We’d kept up to date with each Java release version as soon as it came out (in a separate branch from our main branch). Java 16 has given us significant out-of-the-box performance gains in terms of startup times, memory management, and code execution. It has also given our developers a boost in their productivity with new features like var, switch expressions, text blocks and more!
We are currently evaluating Java 17 with Microsoft, since it is an LTS release it makes sense to roll it out sometime in the future, but we are not giving a specific date yet.
InfoQ: Can you describe the migration process? How smooth was it? How long did the migration take?
Since we were up to date with every major release, we avoided the big bang migration and it wasn’t too difficult. The previous migration challenges arose from moving from Java 8 to Java 11 due to the modular system that introduces stricter security controls for access to JDK internals that some of our 3rdapprox Party dependencies on which one relied at the time.
We recommend every serious Java shop to set up its CI / CD in such a way that it integrates every major version. You can then gradually update your dependencies and code to take advantage of the new features. Once you get used to it, it’s a relatively low upgrade cost that means a big win every time!
InfoQ: You have been running JDK 16 in production for some time now. What improvements have you noticed compared to the previous setup?
Lots of out-of-the-box performance gains with startup times from sharing application and class data, storage efficiency gains from string deduplication in the G1 Garbage Collector, a smoother experience because there are fewer long breaks from GC, and a host of other small improvements. An upgrade is worthwhile from an operational point of view!
InfoQ: Was there anything that you expected would happen with Java 16, but which didn’t happen?
We didn’t have disappointed expectations per se, it was very successful. What was interesting was that we weren’t sure how fast it would be Mod community would use the new language features. The response has been overwhelmingly positive, having access to the latest features is really important for developer productivity!
InfoQ: Which Java version are you using? Is it Microsoft’s? If so, what was the inspiration for using it?
It’s the Microsoft build of OpenJDK. Microsoft has made large long-term investments in Java (like the jClarity acquisition in 2019). You have a very capable Java engineering group that has already made significant contributions to Java itself (like the Windows ARM port). They also share our love for Minecraft, we know we are in good hands.
InfoQ: What were the most difficult technical issues during the migration?
There were three main challenges:
- One just made sure we updated all 3approx Party dependencies on versions that also support Java 16, such as B. the Lightweight Java Gaming Library (LWGL).
- Make sure changes in UI toolkits, fonts, sound, etc. were still compatible.
- Reconfiguring the new garbage collectors and other JVM tuning parameters to take full advantage of the new changes.
InfoQ: What would you have wanted to know before the migration, but didn’t?
There have been multiple guides and blog posts, but not really one canon source for migrating through each version. It wasn’t a blocker, but we had to piece the information together a bit. Microsoft’s guide to Transition from Java 8 to 11 was helpful.
InfoQ: What do you have planned next?
From a pure Java perspective, we will continue to work with the Microsoft Java Engineering Group to test each new version of Java as it is released. We’ll no doubt adopt some of these once we’re satisfied with the developers’ stability, performance and productivity gains!
We can’t comment on a specific roadmap right now, but since Microsoft supports the proposed two-year LTS cadence for OpenJDK vendors, it gives us confidence that we can track upgrades at a more regular pace than in the past.
Even if for most companies the LTS releases when upgrading to Minecraft, now a microsoft company, took a leap of faith when upgrading to Java 16. Your expectations in terms of performance increases with start times out-of-the-box due to AppCDS, storage efficiency gains due to string deduplication in the G1 Garbage Collector and an overall smoother experience due to less long breaks from GC.
The new language extensions were also welcomed by the mod community: “The response was overwhelmingly positive, it is really important for your developer productivity to have access to the latest functions!”. These promise that developers can write more elegant code faster.