Details
-
New Feature
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
(copied to CRM)
Description
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.