grails-core icon indicating copy to clipboard operation
grails-core copied to clipboard

Validation is not applied when using @GrailsCompileStatic on domains with inner Enum

Open matrei opened this issue 2 years ago • 1 comments

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

  1. Create a domain class annotated with @GrailsCompileStatic and that has an inner Enum and some validation rules.
  2. 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

matrei avatar Apr 01 '22 06:04 matrei

Possibly related to #10808

matrei avatar Apr 01 '22 07:04 matrei

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

darxriggs avatar May 21 '23 08:05 darxriggs

I have found the root cause and will try to provide a fix.

darxriggs avatar May 21 '23 19:05 darxriggs