Fix Version/s: 11
Compatibility Risk Description:This change should only affect existing users of minimal VM, which explicitly specifies a GC other than SerialGC on the command line. All other GCs have historically always been included in non-minimal VMs.
Interface Kind:add/remove/modify command line option
To avoid unexpected behavior, fail immediately if an unavailable GC is selected by the user on the command line.
If an unavailable GC (e.g. the G1 GC is not present in "minimal" VM builds) is selected by the user on the command line, then the VM issues a warning and continues execution by silently selecting a different/available GC. It's easy to miss the warning and this behavior is bound to cause unnecessary confusion. I propose that we instead fail immediately with an appropriate error message.
This has not been a very big problem so far (essentially only affecting minimal VMs). However, we've recently made it possible to configure which GCs to included/exclude in a VM (using the
--with-jvm-features=cmsgc/epsilongc/g1gc/parallelgc/serialgc/zgc option). Some of these GCs are also "experimental" and some vendors might choose to build them and some might choose not to. As a result, it might become more common to see VMs with different sets of supported GCs built in.
Instead of silently selecting one of the available GCs, fail immediately with an appropriate error message. E.g. "Option -XX:+UseG1GC not supported".
I'm essentially suggesting changing a call to:
to instead be a call to: