Kotlin extension function on parameterized type leads to ArrayIndexOutOfBoundsException during validateParameters
Method constraints validation
Presence of extension function on parameterized type within the validated object
Given the following code making use of method constraint validation
Attempting to execute the code leads to ArrayIndexOutOfBoundsException and the given arguments not being validated:
Debugging reveals that org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider#findExecutableMetaData is retrieving an incorrect JavaBeanExecutable result from JavaBeanHelper when processing the private final void foo.SimpleFooService.someExtensionFunction(java.util.List,int) method:
The extensionFunctionArg argument has the List<String> type associated to it, instead of int
That inconsistency causes AnnotationMetaDataProvider.getTypeParametersCascadingMetaDataForParameterizedType to fail.
Workaround is to remove all extension functions on parameterized receiver from the validated class (which may not be desirable).
Hibernate Validator 6.1.5.Final
zulu11.35.15-ca-jdk11.0.5-win_x64 (observed against IBM Java 8 too)
I would say we can keep it open until we have an answer from the Kotlin team and we are sure they consider it a Kotlin issue.
It seems the problem is upstream in the Kotlin compiler when javaParameters = true as such inconsistency can be reproduced without Hibernate Validator by mere use of reflection APIs.
KT-40857 created against the Kotlin project. I guess you could close this issue as the root cause is out of this project scope.