Using Spring Initilizr

sdk use java 22.3.1.r19-grl Also tried graalvm r17

Added a controller

@RestController
class GreetingHttpController() {
    @GetMapping("/hello/{name}")
    suspend fun greet(@PathVariable name: String): String {
        val UTF_32BE = Charset.forName("UTF-32BE")
        return "Hello $name"
    }
}

Compile and run with

./mvnw native:compile -Pnative
target/demo-utf32be

Call the controller

curl http://localhost:8080/hello/fred

Throws

java.nio.charset.UnsupportedCharsetException: UTF-32BE
        at java.base@19.0.2/java.nio.charset.Charset.forName(Charset.java:537) ~[demo-utf32be:na]

Original Stack Trace:
                at java.base@19.0.2/java.nio.charset.Charset.forName(Charset.java:537) ~[demo-utf32be:na]
                at com.example.demoutf32be.GreetingHttpController.greet$suspendImpl(DemoUtf32beApplication.kt:22) ~[demo-utf32be:na]
                at com.example.demoutf32be.GreetingHttpController.greet(DemoUtf32beApplication.kt) ~[demo-utf32be:an]

Same result with spring boot 3.0.4 I tried a few native hints but with no success, happy to try any suggestions.

I am trying to use the Azure Blob Storage library from native but it fails with this error while initializing.

Comment From: philwebb

I believe that GraalVM doesn't compile will all charsets out of the box. It looks there's a -H:+AddAllCharsets option which might be what you need. I don't think there's much we can do in Spring Boot itself I'm afraid. We can't detect that UTF-32BE will be used, and we don't want to include all charsets by default because it adds a lot of bytes to the image.

Comment From: mickjjfs

Thanks, fix is to add configuration block

<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
    <configuration>
        <buildArgs>
            <arg>-H:+AddAllCharsets</arg>
        </buildArgs>
    </configuration>
</plugin>