[
https://issues.apache.org/jira/browse/BVAL-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17471159#comment-17471159
]
Matthew Jason Benson commented on BVAL-213:
-------------------------------------------
Hello [~charles.jourdan] with my apologies for the long delay. Please see
[https://beanvalidation.org/2.0/spec/#constraintdeclarationvalidationprocess-methodlevelconstraints-inheritance]
where the third bullet point explains that it is illegal to mark parameters of
overridden methods for cascaded validation.
> [bval-jsr] Illegal strengthening: overridden [constraints] in inheritance
> hierarchy
> -----------------------------------------------------------------------------------
>
> Key: BVAL-213
> URL: https://issues.apache.org/jira/browse/BVAL-213
> Project: BVal
> Issue Type: Bug
> Affects Versions: 2.0.3, 2.0.5
> Environment: I'm using Bval which is embedded in TomEE.
> I tested the version 2.0.3 and 2.0.5, maybe more version have this problem.
> Reporter: Charles Jourdan
> Priority: Major
>
> {{I encountered this exception when creating a bean. I'm not really sure if
> it is a bug or a misuse.}}
> {code:java}
> javax.validation.ConstraintDeclarationException: Illegal strengthening:
> overridden [constraints] in inheritance hierarchy: [method1, method2]
> {code}
> The two methods have exactly the same annotations. There is two classes with
> an inheritance. The mother is an abstract generic class and the child is a
> simple implementation of the mother.
> The exception is thrown by the enum StrengtheningIssue in Liskov
> (overridenHierarchy value).
> After debugging this part I observed an akward situation. The parameter
> detectedValidationElements have 2 two entries, normal. The child class is in
> first position followed by the mother class, but the algorithm use the first
> class to test the isAssignableFrom. So it will be always false in case of
> inheritance.
> After some research I found the method
> org.apache.bval.jsr.metadata.HierarchyBuilder#forBean which is called by the
> org.apache.bval.jsr.descriptor.DescriptorManager#getBeanDescriptor. The
> method forBean is responsible of the list with the bad order. It adds the
> parent in second position, so I supposed the bug source is in this method.
> I have no idea about the impact of this order on other places. I'm not really
> if this is a bug, but I found this really akward.
> I hope it is understadable, and sorry for my bad english.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)