[JAVA-5219] Provide GraalVM metadata and substitutions Created: 31/Oct/23  Updated: 24/Jan/24

Status: Backlog
Project: Java Driver
Component/s: Integrations
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: clement escoffier Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File MongoClientSubstitutions.java    
Quarter: FY24Q4
Case:
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 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.



 Comments   
Comment by PM Bot [ 31/Oct/23 ]

Hi clement.escoffier@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Thu Feb 08 09:04:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.