spring version: 6.1.8

example:

data class Nullable(
    val isX: Boolean?
)

@SpringBootApplication
@RestController
class Application {
    @GetMapping("/")
    fun nullable() = Nullable(true)
}

response:

{"timestamp":"2024-08-13T15:14:13.916+00:00","status":500,"error":"Internal Server Error","path":"/"}

stack trace:

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public final java.lang.Boolean org.example.springnativeimageboxedtypeissuereproduction.Nullable.isX() without it being registered for runtime reflection. Add it to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:97) ~[na:na]
        at java.base@17.0.10/java.lang.reflect.Method.acquireMethodAccessor(Method.java:77) ~[spring-native-image-boxed-type-issue-reproduction:na]
        at java.base@17.0.10/java.lang.reflect.Method.invoke(Method.java:566) ~[spring-native-image-boxed-type-issue-reproduction:na]
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:688) ~[spring-native-image-boxed-type-issue-reproduction:2.17.2]
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770) ~[spring-native-image-boxed-type-issue-reproduction:2.17.2]
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183) ~[na:na]
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502) ~[spring-native-image-boxed-type-issue-reproduction:2.17.2]
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:341) ~[spring-native-image-boxed-type-issue-reproduction:2.17.2]
        at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1574) ~[na:na]
        at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1061) ~[spring-native-image-boxed-type-issue-reproduction:2.17.2]

issue reproduction repository: https://github.com/czp3009/spring-native-image-boxed-type-issue-reproduction

Possible causes: The class BindingReflectionHintsRegistrar not consider the java boxed type 'Boolean' but kotlin nullable type will compiled into boxed type https://github.com/spring-projects/spring-framework/blob/1aea01687af86bb2a8528c44f690b5877a682923/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java#L112

the code simply inference the java primitive type 'boolean''

if a method name starts with 'is' and return type is 'Boolean', the method will not be registered to native hint

Comment From: izeye

This seems to be a bug but hasn't been labeled accordingly, so this seems to be missing in the release notes.

Comment From: bclozel

Thanks @izeye I've updated the release notes.