Exclude LocalVariableTableParameterNameDiscoverer based on native image check

See gh-29531
This commit is contained in:
Juergen Hoeller 2022-11-22 15:37:00 +01:00
parent d32027df92
commit 7816c9e411
1 changed files with 3 additions and 5 deletions

View File

@ -16,13 +16,11 @@
package org.springframework.core;
import org.springframework.aot.AotDetector;
/**
* 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} (when not using
* AOT-processed optimizations) for checking debug information in the class file.
* to the ASM-based {@link LocalVariableTableParameterNameDiscoverer} (when not in
* a native image) for checking debug information in the class file.
*
* <p>If a Kotlin reflection implementation is present,
* {@link KotlinReflectionParameterNameDiscoverer} is added first in the list and
@ -45,7 +43,7 @@ public class DefaultParameterNameDiscoverer extends PrioritizedParameterNameDisc
addDiscoverer(new KotlinReflectionParameterNameDiscoverer());
}
addDiscoverer(new StandardReflectionParameterNameDiscoverer());
if (!AotDetector.useGeneratedArtifacts()) {
if (!NativeDetector.inNativeImage()) {
addDiscoverer(new LocalVariableTableParameterNameDiscoverer());
}
}