Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.x, 2.6.0-alpha-1, 2.4.12, 2.5.0-beta-2
-
None
Description
In java, enums that are nested classes have the static modifier set i.e. if Bar is an enum defined within a class Foo, assert Modifier.isStatic(Foo.Bar.modifiers) passes. The assertion does not hold if Foo and Bar are defined in groovy:
class Foo { enum Bar { X } } assert java.lang.reflect.Modifier.isStatic(Foo.Bar.modifiers)
This can be problematic in cases like https://mongodb.github.io/morphia/, where the type of a mapped field cannot be a non-static inner class. Of course that library could also be more enum-aware when validating mapped fields, but that's a separate issue.
A simple workaround for this issue is to explicitly declare the enum as static, so it's not critical that a patch for this be in 2.4.X if it's considered a breaking change (though no tests fail with the change.)
Attachments
Issue Links
- links to