spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

aot seems to ignore @MethodHint with primitive type parameter #1614

Closed lambliesdown closed 1 year ago

lambliesdown commented 2 years ago

While trying to track down an issue with the HttpComponentsClientHttpRequestFactory I found the following. I have a @NativeHint similar to the ClientHttpRequestFactoryHints.

@NativeHint(types = { @TypeHint(types = org.springframework.http.client.HttpComponentsClientHttpRequestFactory.class, methods = { @MethodHint(name = "setConnectTimeout", parameterTypes = int.class), @MethodHint(name = "setReadTimeout", parameterTypes = int.class), @MethodHint(name = "setHttpClient", parameterTypes = HttpClient.class), @MethodHint(name = "setBufferRequestBody", parameterTypes = boolean.class), }) })

Running 'gradle generateAot' on this generates { "name": "org.springframework.http.client.HttpComponentsClientHttpRequestFactory", "allDeclaredConstructors": true, "methods": [ { "name": "setHttpClient", "parameterTypes": [ "org.apache.http.client.HttpClient" ] } ] }

If you specify a non-primitive type parameter, the method shows up.

The @NativeHint in ClientHttpRequestFactoryHints generates { "name": "org.springframework.http.client.HttpComponentsClientHttpRequestFactory", "condition": { "typeReachable": "org.apache.http.client.HttpClient" }, "allDeclaredConstructors": true },

sdeleuze commented 1 year ago

Spring Native is now superseded by Spring Boot 3 official native support, see the related reference documentation for more details.

As a consequence, I am closing this issue, and recommend trying your use case with latest Spring Boot 3 version. If you still experience the issue reported here, please open an issue directly on the related Spring project (Spring Framework, Data, Security, Boot, Cloud, etc.) with a reproducer.

Thanks for your contribution on the experimental Spring Native project, we hope you will enjoy the official native support introduced by Spring Boot 3.