grails-core
grails-core copied to clipboard
Validation is not applied when using @GrailsCompileStatic on domains with inner Enum
Expected Behavior
When validating a domain object that is annotated with @GrailsCompileStatic
, and that has an inner Enum
, the validation rules in the constraints block of the domain object should be followed.
Actual Behaviour
The validation rules are not applied.
Steps To Reproduce
- Create a domain class annotated with @GrailsCompileStatic and that has an inner Enum and some validation rules.
- Write a test that tests the validation rules.
or clone the example application and run the tests.
Environment Information
- Operating System: tested on Ubuntu 20.04
- JDK Version: tested with 8 and 11
Example Application
https://github.com/matrei/grails-compile-static-validation-bug
Version
5.1.5
Possibly related to #10808
I have some more findings.
The issue is not only about inner enums but also about inner classes.
The issue is not only about the constraints
closure but also about the mapping
closure.
Both of them are not called when @GrailsCompileStatic
is used on the domain class.
When using @GrailsCompileStatic
on the domain class and @CompileDynamic
on the inner enum/class,
both closures are called (the same way as when not using @GrailsCompileStatic
on the domain class).
I have found the root cause and will try to provide a fix.