How does Micronaut manage to run on GraalVM?

    How can I make a Micronaut application that uses picocli run on GraalVM?

    Picocli provides a picocli-codegen module with a tool for generating a GraalVM reflection configuration file. The tool can be run or automatically as part of the build. The module’s README has usage instructions with code snippets for configuring Gradle and Maven to generate a cli-reflect.json file automatically as part of the build. Add the generated file to the -H:ReflectionConfigurationFiles option when running the native-image tool.

    What about other Third-Party Libraries?

    Micronaut cannot guarantee that third-party libraries work on GraalVM SubstrateVM, that is down to each individual library to implement support.

    I Get a “Class XXX is instantiated reflectively…​” Exception. What do I do?

    You may need to manually tweak the generated reflect.json file. For regular classes you need to add an entry into the array:

    1. [
    2. "name" : "myclass.Foo",
    3. "allDeclaredConstructors" : true
    4. ...
    5. ]

    For arrays this needs to use the Java JVM internal array representation. For example:

    What if I want to set the heap’s maximum size with -Xmx, but I get an OutOfMemoryError?

    The problem is that Netty is trying to allocate 16MiB of memory per chunk with its default settings for io.netty.allocator.pageSize and io.netty.allocator.maxOrder:

    The simplest solution is to specify io.netty.allocator.maxOrder explicitly in your Dockerfile’s entrypoint. A working example with -Xmx64m:

    1. ENTRYPOINT ["/app/application", "-Xmx64m", "-Dio.netty.allocator.maxOrder=8"]