When you use reflection on your project and compiles it to a native-image binary you could have issues while running this executable cause it has some limitations on reflection. Basicaly everything that is not explicitly referenced at the code will be removed by native-image at compiling time and won't be available at runtime.
Native image gives you some options to bypass this problem
If you use Jackson for example there is no exit, you will have to manually configure your classes for reflection support.
Problem is: it is very hard to have to configure every class at the reflect.json
every time you create one, also, the chance of you forget to do such configuration is too high, in the end your software will work in java version but not in binary, that's not good.
Let me present Graal Reflection Configuration Generator to you, using it you won't have to create JSON files and configure every class, you can annotate the class which you want to be available for reflection, you can also configure a entire package to be scanned for you. No additonal configuration, when you compile your program GRCG will automatically make all the necessary configuration for you.
Using annotation processors GRCG scan for annotated classes or packages, generate a reflect.json and attach it at the jar resources, this way native-image will be able to register these classes and everything will work when you run your compiled program.
Just configure GRCG in your dependencies, you just need it at compile time, then it won't make your program bigger.
Configuring on gradle
dependencies {
compileOnly("com.mageddo.nativeimage:reflection-config-generator:2.3.4")
annotationProcessor("com.mageddo.nativeimage:reflection-config-generator:2.3.4")
}
Configuring on maven
<dependencies>
<dependency>
<groupId>com.mageddo.nativeimage</groupId>
<artifactId>reflection-config-generator</artifactId>
<version>2.3.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Configuring on vanilla java
javac -cp reflection-config-generator.jar Main.java
Creating a config class
@Reflection(declaredConstructors = true, declaredFields = true, scanPackage = "com.github.vo")
public class Config {}
This way it will scan all com.github.vo
package classes. See see working samples for more details