r/JavaFX • • 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

24 comments sorted by

View all comments

Show parent comment

1

u/davidalayachew Apr 11 '24

Hmmm, actually, I am a little suspect of the first example. Could you try and do a fresh compile again? I just realized that it is grabbing the parameter, not the instance field.

/u/colindj1120