Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.8.0
-
None
Description
Here is a test that I've been running in the LazyInitOnClassNodeTest class.
void testLazyInit2() { ClassNode listType = ClassHelper.make(RetentionPolicy.class) // listType.getFields() FieldNode fn = listType.getField "SOURCE" assert fn!=null }
Like that, it will fail. If the call to getFields() is uncommented, it will pass. This is due to lazy class initialization not running if getFields() isnt run (or some other method that triggers the lazy init). I fixed it by adding:
if (!redirect().lazyInitDone) redirect().lazyClassInit();
to getDeclaredField() (used from getField) - but that may not be the best way.
I haven't checked whether the same problem also affects methods/etc.