What the Future of Java means for Minecraft

Posted on November 28, 2020 in minecraft

Tagged with: minecraft servers, java
What the Future of Java means for Minecraft

There has been a fair amount of talk throughout the community recently about how upcoming versions of Java will massively improve Minecraft's performance. While we can't yet benchmark these changes, we can explore what changes are coming, when they'll likely arrive, and how they're likely to affect Minecraft and servers. This article is for both users and developers, so it skips over some technical details to make it more understandable.

Currently, Java 8 is the recommended version of Java for Minecraft. While it's possible to run on newer versions, and many servers do, Mojang officially recommends Java 8. This recommendation will likely change in the future as some of these changes come to Java. Due to this, the article will also include some released features in versions of Java that are beyond Java 8.

Garbage Collectors

The most short term changes that will improve Minecraft are changes to the garbage collector. A garbage collector is a system that cleans up any memory that the application is no longer using. While it may seem simple, these are very time-intensive and complicated pieces of code. With every Java release, there are improvements to the included garbage collectors.

As of Java 9, a newer garbage collector known as the G1 Garbage Collector has been the default. While available in Java 8, it wasn't the default. This garbage collector performs significantly better with Minecraft than the old default, and even more so with improvements that have come to it since it became the default. The improved garbage collector is one of the main reasons why many servers use Java 11 over Java 8. Members of the Minecraft server community, such as Aikar, have also done a fantastic job of tweaking the G1 garbage collector and documenting their findings.

G1 isn't the only new garbage collector. Both Shenandoah and ZGC have come about in recent versions of Java, and boast rather impressive performance stats. While both of these appear to run faster than G1 in general use cases, they have not been heavily researched or tested on Minecraft servers. Due to this, using G1GC with Aikar's tweaks is likely a better idea unless you wish to perform some experimentation. Shenandoah is significantly more likely to end up being a better garbage collector for Minecraft than ZGC however, as it is more optimised for the kind of memory output that Minecraft creates.

Project Panama (Native Access)

Project Panama aims to improve the way Java applications access lower-level aspects of the machine. Most of Panama's contents will arrive as preview features in Java 16, to hopefully receive full release shortly after.

This project will not directly impact Minecraft, but some of the dependencies that the game uses can make use of it to improve performance. The most significant benefit is on the client, where the rendering library the game uses (LWJGL) can make use of Panama to improve performance. The networking library in the game (Netty) will also likely see a minor improvement, as Java will be able to optimise the code better. As the affected part of the network code in the game is not slow, this will likely not be too noticeable.

One area where Panama is likely to have a significant impact outside of Minecraft itself, however, is any server proxy software. Server proxy software spends almost all of its time handling network code, so a version of Netty that makes use of Panama could theoretically take a more considerable amount of players per proxy.

Project Loom (Virtual Threads)

One of the Java changes likely to come out soon is the virtual threads feature from Project Loom. This feature provides a fast and straightforward way to make small tasks asynchronous or multithreaded. While this will not allow the game to be entirely multithreaded like I've seen some claim, it may improve performance and simplicity of some areas that are already multithreaded such as lighting, networking, or chunk loading (on Paper).

Another massive bonus here is that it will hopefully make it easier for programmers to do the correct thing when writing asynchronous or multithreaded code. This change may mean that more beginner programmers will write plugins for servers that properly make use of threading and asynchronous code.

Recent information indicates that this feature could land as a preview as early as Java 17, but it will likely be a release or two later before it becomes stable. Overall this feature by itself will not improve much, but if code is changed to make proper use of it, there may be some minor improvements.

Project Valhalla (Inline / Value types)

Project Valhalla has somewhat become a familiar name through some areas of the Minecraft server community, with claims that it'll majorly improve performance of Minecraft. The main feature of Valhalla that'll impact Minecraft is Inline Types, formerly known as Value Types.

Currently, the Minecraft codebase is full of containers of memory that store smaller values inside of them. For example, a block position contains three numbers to refer to the x, y, and z coordinates. Without inline types, this container itself takes up memory, as well as the contents. With inline types, the container can exist in the code but will act as if it doesn't exist, only using memory for the contents. This change leads to overall less memory usage, quicker memory allocations, and less work for the garbage collectors.

While inline types likely won't be a "game-changing" improvement, this has the potential to improve performance of the game majorly. Like most of these Java changes, however, this requires Mojang to make the most of it. Valhalla is likely the most significant feature coming to Java in the future from the perspective of Minecraft; however, don't expect it anytime soon. Adding inline types to Java requires a fundamental change to the way it works, as well as ensuring that it doesn't break any previous behaviour.


The future of Java contains some exciting changes, and some can improve Minecraft for the better. These improvements do depend on Mojang updating to a new version of Java and making changes to the game's code, however. Hopefully, at some point, the potential benefits outweigh the time commitment, and Mojang dedicates the time to achieve this. Until then, you can at least try out the new garbage collector improvements.

This article is part of a series on how to run a Minecraft server. Click here to check out more!

Check out these popular related posts!

Should you use MySQL with a Minecraft plugin?

Posted on December 23, 2020

The Minecraft server community has many misconceptions floating around about using MySQL or other databases with plugins, some of which cause servers to perform significantly worse.

Paper vs Spigot, which should you use?

Posted on August 26, 2020

Paper and Spigot are the two leading platforms for Minecraft servers. Which is better? This article goes over the main benefits of using both platforms

Should you use Large Plugins or Multiple Small Plugins?

Posted on July 11, 2020

There is a lot of controversy around large plugins being worse than multiple small plugins, but is it true?