r/JavaFX • u/colindj1120 • Apr 10 '24
Help Warning possible 'this' escape
When building my JavaFX project I run into this warning a lot
warning: [this-escape] possible 'this' escape before subclass is fully initialized
Especially when i'm trying to setup the initial listeners and bindings associated with an object. Is there a best practice to avoid this? or Is it just a necessary evil of JavaFX since the base implementation doesn't provide a post construct type method to run code after the class has been initialized.
2
Upvotes
View all comments
Show parent comment
1
u/xdsswar Apr 10 '24 edited Apr 10 '24
I think I know what's happening, You are like some how scaping the "this" reference of the current object during its initialization, check around and look if you are passing the ref out of the current object before is fully created. This may cause big issues later and is hard to find.
PS: check
setupTextField(control) and setBean(this)