Trying to run a WebMvcTest in a native image leads to:
Failures (1):
JUnit Jupiter:DemoControllerTests
ClassSource [className = 'com.example.demo.DemoControllerTests', filePosition = null]
=> java.lang.IllegalStateException: Unable to create filter for class org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTypeExcludeFilter
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer.instantiateTypeExcludeFilter(TypeExcludeFiltersContextCustomizer.java:68)
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer.instantiateTypeExcludeFilters(TypeExcludeFiltersContextCustomizer.java:53)
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer.<init>(TypeExcludeFiltersContextCustomizer.java:46)
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizerFactory.createContextCustomizer(TypeExcludeFiltersContextCustomizerFactory.java:57)
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizerFactory.createContextCustomizer(TypeExcludeFiltersContextCustomizerFactory.java:51)
[...]
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTypeExcludeFilter.<init>()
java.lang.Class.getConstructor0(DynamicHub.java:3585)
java.lang.Class.getDeclaredConstructor(DynamicHub.java:2754)
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer.getTypeExcludeFilterConstructor(TypeExcludeFiltersContextCustomizer.java:113)
org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer.instantiateTypeExcludeFilter(TypeExcludeFiltersContextCustomizer.java:60)
[...]
Perhaps an inference on TypeExcludeFilters is missing.
Comment From: snicoll
Turns out we shouldn't be contributing hints for this at all since they shouldn't run in a native image. Superseded by #32422.