Skip to content

Consistent Class and array matching in ResolvableType.isAssignableFrom #31487

@jhoeller

Description

@jhoeller

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions