|
In general, subclasses should not define constraints on method parameters that are stricter than those defined in superclasses. There was a detailed discussion on that in
HV-421
.
For instance, In Spring, with validation enabled, if I have two classes like this:
public class A {
public void foo(String s) { ... }
}
public class B extends A {
public void foo(@NotNull String s) { ... }
}
... I get a ConstraintDefinitionException on the first invocation of B.foo and rightly so.
I think the annotation processor should be able to detect this (and other cases cases mentioned in
HV-421
) at compile time. It doesn't seem to do that.
|