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

Consistent Class and array matching in ResolvableType.isAssignableFrom #31487

Closed
jhoeller opened this issue Oct 24, 2023 · 0 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@jhoeller
Copy link
Contributor

jhoeller commented Oct 24, 2023

The ResolvableType.isAssignableFrom algorithm performs a regular matching attempt for nested array component types, including the lenient matching of primitive types versus primitive wrapper types, e.g. considering Integer[] and int[] as assignable. Since the Java compiler matches array components in a strict fashion for assignments, ResolvableType needs to align with this, not expecting any remaining conversion to be performed between primitive and wrapper types after an assignability check.

This brings ResolvableType.isAssignableFrom in line with Class.isAssignableFrom, consistently answering true whenever two Class references wrapped within ResolvableType get compared just like when they get compared via Class.isAssignableFrom itself. Most importantly, this allows for a significant optimization in that we can actually delegate to Class.isAssignableFrom whenever two Class-based ResolvableType instances get compared, speeding up such checks by 5x. The full algorithm is only applied when actual generics are involved.

@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Oct 24, 2023
@jhoeller jhoeller added this to the 6.1.0-RC2 milestone Oct 24, 2023
@jhoeller jhoeller self-assigned this Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant