Describe the bug
The @ReflectionHint(types = { Result.class }) does not seem to work for inner static classes.
To Reproduce
Steps to reproduce the behavior:
- Create a file with the following content
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 21+
//DEPS io.goodforgod:graalvm-hint-processor:1.1.0
//DEPS io.goodforgod:graalvm-hint-annotations:1.1.0
//DEPS com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.0
import static java.lang.System.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import io.goodforgod.graalvm.hint.annotation.ReflectionHint;
public class TestYaml {
public static void main(String... args) throws JsonMappingException, JsonProcessingException {
out.println("Hello World");
String document = "hello: 25";
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
Result r = objectMapper.readValue(document, Result.class);
out.println(r.hello);
}
public static class Result {
public Integer hello;
}
//@ReflectionHint(typeNames = {"TestYaml$Result"})
@ReflectionHint(types = { Result.class })
public class ReflectionConfig {}
}
- Execute it with jbang it should display
- when exporting the script
jbang export native --force --verbose TestSnakeYaml.java the execution of the binary yields the following error
Hello World
Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `TestYaml$Result`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
at [Source: (StringReader); line: 1, column: 1]
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1887)
- If the comment is switched to the
typeNames it works.
Expected behavior
Should work in both cases.
Describe the bug
The
@ReflectionHint(types = { Result.class })does not seem to work for inner static classes.To Reproduce
Steps to reproduce the behavior:
jbang export native --force --verbose TestSnakeYaml.javathe execution of the binary yields the following errortypeNamesit works.Expected behavior
Should work in both cases.