[bv-dev] Method constraints in inheritance hierarchies

Denis Silva denis.analistajava at gmail.com
Sat Jul 6 13:29:45 EDT 2013


Hi,

I'm doing some tests with bean validation, and i have some doubts about the
behavior of method constraints on inheritance hierarchies.
The specification tells about Liskov substitution, on method constraints
within inheritance hierarchies, but i made the test bellow with
the reference implementation ( hiberante validator 5.1 ), and not
understand if this is a bug in implementation or my misunderstanding the
specification.

public interface Foo {
     public void doStuff(@NotNull String v);
}

@Named
public class Bar implements Foo {
     public void doStuff(String v) {}
}

Calling bar.doStuff(null), the validation is not fired.
But if i changed Foo interface to an abstract class, and made Bar extends
it, the validation is fired and a ConstraintViolationException is
propagated.
The test was done with cdi.

What should be the appropriate behavior?

-- 
Denis Tiago
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/beanvalidation-dev/attachments/20130706/ecece65d/attachment.html 


More information about the beanvalidation-dev mailing list