Annotation Processor doesn't detect errors in parameter constraints in inheritance hierarchies

Description

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:

... 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.

Environment

None

Activity

Gunnar MorlingDecember 12, 2013 at 8:20 AM

Hi Alina, thanks for the report. The annotation processor can't yet deal with parameter constraints, also see and HV-801.

Would you be interested in implementing this feature? The processor is based on JSR 269 and makes it very easy to provide new constraint checks by implementing ConstraintCheck and registering them in ConstraintCheckFactory. Finding out whether one method overrides another one is even easier within the annotation processor than at runtime as one can use Elements#overrides().

Fixed

Details

Assignee

Reporter

Labels

Participants

AlinaM
Gunnar Morling
Marko Bekhta

Pull Request

Components

Fix versions

Affects versions

Priority

Created December 11, 2013 at 11:05 PM
Updated December 8, 2016 at 11:32 AM
Resolved November 30, 2016 at 1:02 PM