When running org.springframework.test.web.servlet.samples.spr.EncodedUriTests in AOT mode via AotIntegrationTests#endToEndTestsForEntireSpringTestModule(), we encounter the following exception.

org.springframework.core.test.tools.CompilationException: Unable to compile source

org.springframework.test.web.servlet.samples.spr.EncodedUriTests.MyController has private access in org.springframework.test.web.servlet.samples.spr.EncodedUriTests /org/springframework/test/web/servlet/samples/spr/EncodedUriTests__TestContext001_BeanDefinitions.java 27:56
org.springframework.test.web.servlet.samples.spr.EncodedUriTests.HandlerMappingConfigurer has private access in org.springframework.test.web.servlet.samples.spr.EncodedUriTests /org/springframework/test/web/servlet/samples/spr/EncodedUriTests__TestContext001_BeanDefinitions.java 44:56

Resulting from the attempt to compile the following.

package org.springframework.test.web.servlet.samples.spr;

import org.springframework.beans.factory.aot.BeanInstanceSupplier;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;

/**
 * Bean definitions for {@link EncodedUriTests}.
 */
public class EncodedUriTests__TestContext001_BeanDefinitions {
  /**
   * Bean definitions for {@link EncodedUriTests.WebConfig}.
   */
  public static class WebConfig {
    /**
     * Get the bean definition for 'webConfig'.
     */
    public static BeanDefinition getWebConfigBeanDefinition() {
      RootBeanDefinition beanDefinition = new RootBeanDefinition(EncodedUriTests.WebConfig.class);
      beanDefinition.setInstanceSupplier(EncodedUriTests.WebConfig::new);
      return beanDefinition;
    }

    /**
     * Get the bean instance supplier for 'myController'.
     */
    private static BeanInstanceSupplier<EncodedUriTests.MyController> getMyControllerInstanceSupplier(
        ) {
      return BeanInstanceSupplier.<EncodedUriTests.MyController>forFactoryMethod(EncodedUriTests.WebConfig.class, "myController");
    }

    /**
     * Get the bean definition for 'myController'.
     */
    public static BeanDefinition getMyControllerBeanDefinition() {
      RootBeanDefinition beanDefinition = new RootBeanDefinition(EncodedUriTests.MyController.class);
      beanDefinition.setInstanceSupplier(getMyControllerInstanceSupplier());
      return beanDefinition;
    }

    /**
     * Get the bean instance supplier for 'myHandlerMappingConfigurer'.
     */
    private static BeanInstanceSupplier<EncodedUriTests.HandlerMappingConfigurer> getMyHandlerMappingConfigurerInstanceSupplier(
        ) {
      return BeanInstanceSupplier.<EncodedUriTests.HandlerMappingConfigurer>forFactoryMethod(EncodedUriTests.WebConfig.class, "myHandlerMappingConfigurer");
    }

    /**
     * Get the bean definition for 'myHandlerMappingConfigurer'.
     */
    public static BeanDefinition getMyHandlerMappingConfigurerBeanDefinition() {
      RootBeanDefinition beanDefinition = new RootBeanDefinition(EncodedUriTests.HandlerMappingConfigurer.class);
      beanDefinition.setInstanceSupplier(getMyHandlerMappingConfigurerInstanceSupplier());
      return beanDefinition;
    }
  }
}

Since MyController and HandlerMappingConfigurer are private static classes in EncodedUriTests, we cannot access their types via EncodedUriTests.MyController and EncodedUriTests.HandlerMappingConfigurer.

The same failure occurs for the private static classes in org.springframework.test.web.servlet.samples.spr.HttpOptionsTests.

Comment From: snicoll

This is a general problem with AOT that needs to be able to write code that represents the state of the bean factory. We're not going to use full reflection for this so those types must be package visible at a minimum.

Comment From: sbrannen

those types must be package visible at a minimum.

I addressed that in 3ad79e919bab6eaa1986bd8504a8c5be3ac41dc3.