To compile a Java application using Mongo into a native executable with GraalVM, you need:
- a set of metadata configuring the compiler
- a set of substitutions that transform the code during the native compilation
The substitutions are there to reduce the footprint of the resulting executable and workaround features not supported by the native compiler.
This issue is about migrating substitutions and metadata available in the Quarkus Mongo extension to the Mongo Java client project. It will simplify the maintenance and will prevent changes from breaking native compilation.
The idea would be to:
- include the substitutions (files attached to this issue). You will need an additional (in the provided scope) dependency: org.graalvm.sdk:graal-sdk
- add a META-INF/mongo/native-image.properties file in one of the artifact with the following metadata:
Add the resource: com.mongodb.spi.dns.DnsClientProvider
Register for reflection
- com.mongodb.client.model.changestream.ChangeStreamDocument
- com.mongodb.client.model.changestream.UpdateDescription
- org.bson.types.ObjectId
Initialize at runtime:
- org.bson.types.ObjectId
- com.mongodb.internal.dns.DefaultDnsResolver
The GraalVM gradle plugin should allow adding a few tests to make sure it works as expected.
PS: I'm the main author of the MongoDB substitution and metadata from the Quarkus extension.
- has to be done after
-
JAVA-5523 Release mongocrypt 1.11
- Closed
- has to be done before
-
JAVA-5196 Add MongoDB Java Driver to List of GraalVM-Tested Libraries
- In Code Review
- has to be finished together with
-
JAVA-5408 Remove GraalVM reachability metadata specific to org.mongodb:mongodb-crypt from :driver-core
- Closed
- is duplicated by
-
JAVA-5381 Add the reachability metadata from graalvm-native-image-app to driver JARs
- Closed
- is related to
-
JAVA-3537 GraalVM support
- Closed
- links to