SpringExtension#getApplicationContext is public API available to anyone building integration with a test that uses SpringExtension. There are certain callbacks that happen early and we should not use that method as it will load the context too soon.
I think the Javadoc of this method deserves a warning. First of all, it's not obvious it'll load the context if necessary (vs. the method being merely a way to retrieve the ApplicationContext from the ExtensionContext).
I've been told ParameterResolver#supportParameter is one of those callbacks where we can't use the context. Looking at the Javadoc of ParameterResolver there is a way to figure that out as long as you understand how SpringExtension works and when it should ideally load the context. Linking that information in the Javadoc of SpringApplication#getApplicationContext would be worthwhile as well.
Comment From: sbrannen
Indeed, there's room for improvement there.
For a bit of background, that method was not originally intended to be a public API, and the documentation is therefore a bit sparse.
However, since the method is public (see #19903), it certainly makes sense to document the behavior and semantics for third parties.
With the changes introduced in conjunction with #35697, we should also document that the "current" ExtensionContext may not be the desired one.