Add jni-config generation
This commit adds support generating graalvm `jni-config.json` file. Configuration format for jni/reflection in graalvm is documented to be exactly same so we can re-use facilities for reflection hints which should be relatively clean for a user as also graalvm uses same classes for both jni/reflection. Closes gh-29007
This commit is contained in:
committed by
Sébastien Deleuze
parent
6902ff77d9
commit
135f9070c5
@@ -49,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link FileNativeConfigurationWriter}.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Janne Valkealahti
|
||||
*/
|
||||
public class FileNativeConfigurationWriterTests {
|
||||
|
||||
@@ -149,6 +150,23 @@ public class FileNativeConfigurationWriterTests {
|
||||
]""", "reflect-config.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
void jniConfig() throws IOException, JSONException {
|
||||
// same format as reflection so just test basic file generation
|
||||
FileNativeConfigurationWriter generator = new FileNativeConfigurationWriter(tempDir);
|
||||
RuntimeHints hints = new RuntimeHints();
|
||||
ReflectionHints jniHints = hints.jni();
|
||||
jniHints.registerType(StringDecoder.class, builder -> builder.onReachableType(String.class));
|
||||
generator.write(hints);
|
||||
assertEquals("""
|
||||
[
|
||||
{
|
||||
"name": "org.springframework.core.codec.StringDecoder",
|
||||
"condition": { "typeReachable": "java.lang.String" }
|
||||
}
|
||||
]""", "jni-config.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resourceConfig() throws IOException, JSONException {
|
||||
FileNativeConfigurationWriter generator = new FileNativeConfigurationWriter(tempDir);
|
||||
|
||||
Reference in New Issue
Block a user