Closed
Description
Take the following kotlin @Service
:
@Service
class Service(
private val applicationContext: ApplicationContext,
private val client: Client = Client()
)
When running on JVM the code behaves as expected: only the constructor parameter without a default value is autowired.
When running the native image the application does not start and throws the following exception indicating that spring
attempts to autowire all constructor parameters (even the one with a default value):
java.lang.NullPointerException: Parameter specified as non-null is null: method de.darkatra.kotlindiissue.Service.<init>, parameter client
Reproducer with details: https://github.com/DarkAtra/spring-native-kotlin-di-issue
Affected Spring Framework versions: 6.0.2
, 6.0.3
, 6.0.4
(verified by building the current spring-boot main branch locally)