I recently refactored the reflection code of my framework to support using traits to share fields. The shared fields are initialized during field declaration (i.e. not in a ctor) for user convenience (they represent columns in a table). In this particular case, fields needed to be passed as parameters to to other field's ctors. In this case the problem is, that the fields passed to other fields ctors seem to alwys be null. The same code constructs have been working for years when using them directly inside a class.
There is a known bug in trait initialization for final fields:
It's on my list to fix before 2.5.0 final. Happy for any assistance.
On Sun, Mar 11, 2018 at 6:37 AM, MG <[hidden email]> wrote:
thank you for the feedback (I searched the Groovy Jira, but was using "field assignment" as the search term, so missed this issue).
Weird bug, just taking away all the final qualifiers actually works, no @Lazy required - I didn't even test that far, since that is such a general problem, that I would have thought people would already have complained about this in troves...
On 10.03.2018 22:10, Paul King wrote:
|Free forum by Nabble||Edit this page|