Consider enabling `VAR_HANDLE` to be build-time initialized to enable `VarHandle` in native image
Author: galderzCreated Sep 21, 2026Updated Sep 21, 2026
FAO @yawkat
Netty can't enable VarHandle in native image due to performance issues. One of those issues is https://github.com/oracle/graal/issues/14476
If PlatformDependant.VAR_HANDLE could be initialized at build time, the issue above could be worked around.
To resolve VAR_HANDLE Netty checks the java version (which also checks if it's Android), checks whether the platform supports alignment, and checks if VarHandle can be correctly instantiated.
It's unclear if all of these checks could be deferred to build time. If they can be deferred, VAR_HANDLE should be refactored to a separate class that can specified as build-time initialized.
Source: netty/netty