aws-sdk-java-v2
aws-sdk-java-v2 copied to clipboard
Resource and JNI configuration files to support CRT in GraalVM native image
Motivation and Context
These changes are required to allow customers to build GraalVM native images that utilize the AWS CRT libraries. This may be starting point to address issues raised in #2948.
Modifications
I ran the GraalVM agent to gather the initial JNI configuration. Then I had to tune the results by:
- Forcing
java.nio.Bufferandjava.nio.ByteBufferto include all constructors, methods, and classes - Including all resources that end in
.so,.dylib,.dll
Testing
I have tested this with Gradle on a separate application that interacts with Greengrass V2's IPC. I believe that it will need some modifications to work in other contexts.
For completeness the only classes that my IPC code references directly in CRT are:
software.amazon.awssdk.crt.io.ClientBootstrapsoftware.amazon.awssdk.crt.io.EventLoopGroupsoftware.amazon.awssdk.crt.io.SocketOptions
jdeps provides this list of dependencies it detected:
software.amazon.awssdk.crt.io.ClientBootstrap
software.amazon.awssdk.crt.io.ClientTlsContext
software.amazon.awssdk.crt.io.EventLoopGroup
software.amazon.awssdk.crt.io.HostResolver
software.amazon.awssdk.crt.io.SocketOptions
software.amazon.awssdk.crt.io.SocketOptions$SocketDomain
software.amazon.awssdk.crt.io.SocketOptions$SocketType
So it is possible that applications that depend on CRT classes outside of these may not work.
Some tuning code be done on:
java.nio.Bufferandjava.nio.ByteBufferto use only the required elements. I couldn't get this working without everything but there may be some things that could be trimmed.jni-config.jsonmight have extra classes referenced that are not needed. I tried trimming this down but eventually fell back onto the default output of GraalVM's agent.
It is likely Maven configuration will need to be done to pick up the binaries and put them in a place where GraalVM native image can find them. Without building a specific task to copy the binaries to my build/resources directory in Gradle the resource-config.json did not work.
Here is the Gradle snippet I used to bring the binaries into my resources directory to get resource-config.json working
https://gist.github.com/timmattison/f4e1dbb165607c168e8b3f0ca2296d33
Thank you for the submission @timmattison, we'll review it shortly, most likely next week.
Is there any news on it? How can I help, I also met the same problem.. :cry:







