Introspection for an abstract class doesn't override the instantiation methods trying to instantiate the abstract class.
Actual Behaviour
For Java and Kotlin, the introspection for abstract classes is overriding the instantiation methods with a call to the abstract class constructor. This results in a j.l.InstantiationError instead of a i.m.c.r.e.InstantiationException.
This is important in my use case because only the latter is caught by micronaut serde and then wrapped in a SerdeException.
Expected Behavior
Introspection for an abstract class doesn't override the instantiation methods trying to instantiate the abstract class.
Actual Behaviour
For Java and Kotlin, the introspection for abstract classes is overriding the instantiation methods with a call to the abstract class constructor. This results in a
j.l.InstantiationError
instead of ai.m.c.r.e.InstantiationException
.This is important in my use case because only the latter is caught by micronaut serde and then wrapped in a
SerdeException
.Note that it already works for groovy classes.
Steps To Reproduce
See the changes in the tests at https://github.com/micronaut-projects/micronaut-core/compare/4.5.x...rorueda:issue-abstract-class-introspection
Note it also has a fix inspired by the groovy implementation (making the
ClassElement
ignore the constructors if the class is abstract).Environment Information
No response
Example Application
No response
Version
core 4.5.x