Jakarta Bean Validation

BVAL-498 Obtain parameter names through reflection

Table of Contents

1. Problem

Violations of constraints on method/constructor parameters refer to the name of the parameter. Prior to Java 8, there was no standardized way for obtaining parameter names at runtime, which is why the ParameterNameProvider SPI was introduced in BV 1.1.

In Java 8, parameter name retrieval was added to the reflection API eventually.

2. Proposition

Mandate that the default implementation of ParameterNameProvider of conforming BV providers delegates to Executable#getParameters()/ Parameter#getName(). If the validated method has been compiled without the compiler option -parameters, then the same names as with BV 1.1 will be returned, i.e. arg0, arg1 etc. If parameter names have been enabled by means of that option, the actual parameter names as contained in the source code will be returned.