Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiation methods in introspection of abstract class tries to instantiate the abstract class #10889

Open
rorueda opened this issue Jun 5, 2024 · 0 comments
Labels
lang: groovy Issues or features specific to Groovy

Comments

@rorueda
Copy link
Contributor

rorueda commented Jun 5, 2024

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 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.

Note that it already works for groovy classes.

Steps To Reproduce

See the changes in the tests at 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

@graemerocher graemerocher added the lang: groovy Issues or features specific to Groovy label Jul 1, 2024
rorueda added a commit to rorueda/micronaut-core that referenced this issue Oct 22, 2024
Ignore constructors for abstract classes, so the introspection is
written as not buildable and the instantiation methods in the
introspection are not overridden, trying to call a constructor for an
abstract class.
rorueda added a commit to rorueda/micronaut-core that referenced this issue Oct 22, 2024
Ignore constructors for abstract classes, so the introspection is
written as not buildable and the instantiation methods in the
introspection are not overridden (trying to call a constructor for an
abstract class).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: groovy Issues or features specific to Groovy
Projects
None yet
Development

No branches or pull requests

2 participants