We need a way to opt-in for the use of AOT on the JVM. Right now, we rely on the system property that is set when building a native image (or running with the native image agent with Native Build Tools), but this should be restricted to things that should really behave differently there.
Spring Native has an AotModeDetector
we could use as an inspiration. This will also be relevant for #28205.