Hello,
When using inheritance sometimes I'm getting "arg0" instead of the right name.
Code:
import org.hibernate.validator.parameternameprovider.ParanamerParameterNameProvider;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.NotNull;
import java.lang.reflect.Method;
import java.util.Set;
interface Service {
void sayHello(@NotNull String world);
}
class ServiceImpl implements Service {
@Override
public void sayHello(String world) {}
}
public class Test {
public static void main(String[] args) throws NoSuchMethodException {
ValidatorFactory factory = Validation.byDefaultProvider()
.configure()
.parameterNameProvider(new ParanamerParameterNameProvider())
.buildValidatorFactory();
Validator validator = factory.getValidator();
Service service = new ServiceImpl();
Method sayHello = Service.class.getMethod("sayHello", String.class);
Set<ConstraintViolation<Service>> violations = validator.forExecutables().validateParameters(service, sayHello, new Object[]{null});
System.out.println("violations = " + violations.iterator().next().getPropertyPath());
}
}
Code:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.paranamer</groupId>
<artifactId>paranamer</artifactId>
<version>2.5.5</version>
</dependency>
</dependencies>
possible results:
violations = sayHello.world
violations = sayHello.arg0
I believe the arg0 is coming from implementation and If I put @NotNull in the interface and the implementation I'm getting "world" only.
In a project I'm working on, the object creation is handled by guice (google dependency injection framework) that creates a proxy (iirc) and in this case sometimes I'm getting "arg0".
Is this a bug that I should report?