snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

RESTEasy: generic type argument class not registered in native image #281

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

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:

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$