Describe the bug
When using RESTEasy, generic type argument classes are not registered automatically for native image compilation.
Example - class MyData does not get registered:
Class:
public class ExtendedClass extends BaseClass<MyData> { ... }
Resource:
@GET
@Produces(MediaType.APPLICATION_JSON)
public ExtendedClass getMethod() { ... }
Expected behavior
Generic type argument classes get registered in native image automatically.
Use case is for example a Pagination DTO with a generic type argument, meaning that all the classes that are using it have to be registered explicitly.
User experience will be better if this does not have to be done manually.
Actual behavior
Generic type argument classes are not registered automatically and cause an exception at runtime:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.test.generics.MyData and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.test.generics.ExtendedClass["data"])
(example - issue occurs for both Jackson and JSON-B)
Current solutions to register the class:
@RegisterForReflection annotation (not possible when class is in an external dependency)
adding the class to a reflection-config.properties file (works, but less user friendly IMHO)
Describe the bug When using RESTEasy, generic type argument classes are not registered automatically for native image compilation.
Example - class MyData does not get registered:
Expected behavior Generic type argument classes get registered in native image automatically. Use case is for example a Pagination DTO with a generic type argument, meaning that all the classes that are using it have to be registered explicitly. User experience will be better if this does not have to be done manually.
Actual behavior Generic type argument classes are not registered automatically and cause an exception at runtime:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.test.generics.MyData and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.test.generics.ExtendedClass["data"])
(example - issue occurs for both Jackson and JSON-B)
Current solutions to register the class:
@RegisterForReflection
annotation (not possible when class is in an external dependency)reflection-config.properties
file (works, but less user friendly IMHO)To Reproduce Reproducer can be found on GitHub: https://github.com/PieterjanDeconinck/quarkus-generics-reflection-reproducer
Environment
Additional notes
https://github.com/quarkusio/quarkus/issues/8849
$upstream:8849$