Consistent Class
and array matching in ResolvableType.isAssignableFrom
#31487
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
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. consideringInteger[]
andint[]
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 withClass.isAssignableFrom
, consistently answeringtrue
whenever twoClass
references wrapped withinResolvableType
get compared just like when they get compared viaClass.isAssignableFrom
itself. Most importantly, this allows for a significant optimization in that we can actually delegate toClass.isAssignableFrom
whenever two Class-basedResolvableType
instances get compared, speeding up such checks by 5x. The full algorithm is only applied when actual generics are involved.The text was updated successfully, but these errors were encountered: