I have same problem. It cannot be avoided even using AnnotationParanamer. And the test result is not idempotent and not repeatable. In runtime, at first Hibernate Validator collects ExecuableMetaData for each method. See org.hibernate.validator.internal.metadata.aggregated.ExecuableMetaData$Builder.findParameterMetaData(). This Builder collects these method metadata(e.g. argument name) from Set<ConstrainedExecutable> constrainedExecutables = newHashSet();. As you see, This is a Set. The element is method signature. It is from interfaces and implementations. For the test case above, there are 2 elements in the Set variable, one for sayHello Implementation method, another for interface method. In other use cases, e.g. in Spring,CXF,etc., The implementation maybe is a Proxy object. But it is a HashSet, it means all elements are unsorted. Validator get the argument name always from first element (method signature) of the Set(Iterable). Sometimes the first is interface method that is annotated with @Named("foo"), It is expected result. But if first is a Proxy object or a normal implementation without any Annotation/special-bytecodes/debug-Info, you will get the argument name like "arg#".
|