diff --git a/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java index 67dd75e44919..ed4d886bc97e 100644 --- a/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/DefaultParameterNameDiscoverer.java @@ -19,8 +19,9 @@ /** * Default implementation of the {@link ParameterNameDiscoverer} strategy interface, * using the Java 8 standard reflection mechanism (if available), and falling back - * to the ASM-based {@link LocalVariableTableParameterNameDiscoverer} for checking - * debug information in the class file. + * on the JVM (not in native images) to the ASM-based + * {@link LocalVariableTableParameterNameDiscoverer} for checking debug information + * in the class file. * *

If a Kotlin reflection implementation is present, * {@link KotlinReflectionParameterNameDiscoverer} is added first in the list and @@ -43,7 +44,9 @@ public DefaultParameterNameDiscoverer() { addDiscoverer(new KotlinReflectionParameterNameDiscoverer()); } addDiscoverer(new StandardReflectionParameterNameDiscoverer()); - addDiscoverer(new LocalVariableTableParameterNameDiscoverer()); + if (!NativeDetector.inNativeImage()) { + addDiscoverer(new LocalVariableTableParameterNameDiscoverer()); + } } }