Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.8.6
-
Fix Version/s: 2.0-beta-3
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
The following code produces NPE when the second object is created:
abstract class C { public abstract String f(Object o); private void g(Object val) { println f(val) // NPE when 'y' is created !!! } public C() {this('DEF')} public C(Object val) { g(val) } } class D extends C { public String f(Object o) { return o ? 'Not null' : 'Is null' } } def x = new D() def y = [ 'f' : { it -> return '123' + it } ] as C
Somehow 'this' becomes null when 'f' is invoked in 'g'.
I see. Thanks for the explanation. I've alerady refactored methods so they are not invoked in constructor.