When attempting to start a GemFire Locator or Server, the process immediately crashes and fails to initialize. The node does not start, and the console output or nohup.out log displays the following fatal Java Virtual Machine (JVM) error:
Starting locator [locator-name]
Error: VM option 'UseZGC' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.
Error: The unlock option must precede 'UseZGC'.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Exception occurred when starting the locator, please check the locator log for detailsThis issue is caused by an incorrect ordering of JVM arguments in the GemFire startup configuration.
In certain Java versions, the Z Garbage Collector (ZGC) is classified as an experimental feature. The JVM parses startup arguments strictly from left to right. If the JVM encounters the -XX:+UseZGC flag before it has been explicitly granted permission to use experimental features via the -XX:+UnlockExperimentalVMOptions flag, the parser rejects the command and the JVM fails to start.
To resolve this issue, you must modify the startup script, environment variable, or configuration file (such as a custom wrapper script or gfsh parameter list) to pass the arguments in the correct sequence.
Step 1: Locate the file or script injecting the JVM arguments for this GemFire node.
Step 2: Find the string of -XX parameters.
]Step 3: Swap the order of the two flags so that the experimental unlock flag comes first.
Incorrect Order: ... -XX:+UseZGC -XX:+UnlockExperimentalVMOptions ...
Correct Order: ... -XX:+UnlockExperimentalVMOptions -XX:+UseZGC ...
Step 4: Save the configuration and start the GemFire Locator/Server again.