Replies: 1 comment
|
Great question! There are a few approaches to add your custom classes/records to Option 1: Use the java -cp ... picocli.codegen.aot.graalvm.ReflectionConfigGenerator \
--additional-class=com.example.MyRecord \
--additional-class=com.example.AnotherClass \
com.example.MyCommandThis is the easiest path if you have a few extra classes to add. Option 2: Create a manual Create [
{
"name": "com.example.MyRecord",
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
}
]GraalVM automatically merges all Option 3: Use the GraalVM Tracing Agent (most thorough) Run your app with the tracing agent to auto-generate the config: java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image \
-jar myapp.jar --your-flagsThis generates all necessary config files including The tracing agent approach is particularly good for Jackson since it exercises the actual reflection calls Jackson makes during deserialization. See the picocli GraalVM docs and GraalVM reflection docs for full details. Hope this helps! Let me know if you need clarification. |
Uh oh!
There was an error while loading. Please reload this page.
Hey there,
I'm using Jackson for reading JSONs with Picocli and GraalVM. Unfortunately, most of JSON libraries use reflection for JSON deserialization, and as a result, I have to add them to
reflect-config.json. I wonder if there is any way to point records/classes that would be added to thereflect-config.json.I saw there is a way to provide a custom factory class instead
picocli.codegen.aot.graalvm.ReflectionConfigGeneratorbut before I start doing this, I wanted to ask if there is any easier way to achieve this.Thanks!
All reactions