<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Hello Compiler Dev Team,</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">I have the following code example.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">```java</div><div class="gmail_default" style="font-family:monospace"><br>package Paint;<br><br>import javax.swing.*;<br><br>public class GUI<br>{<br><br>   private final JFrame frame;<br><br>   public GUI()<br>   {<br>   <br>      this.frame = new JFrame();<br>   <br>      this.frame.add(this.createBottomPanel());<br>   <br>   }<br><br>   private final JPanel createBottomPanel()<br>   {<br>   <br>      final JButton save = new JButton();<br>   <br>      save<br>         .addActionListener<br>         (<br>            actionEvent -><br>            {<br>            <br>               this.toString();<br>            <br>            }<br>            <br>         )<br>         ;<br>   <br>      return null;<br>   <br>   }<br><br>}<br></div><div class="gmail_default" style="font-family:monospace">```</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">This is the compile command that I used.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">```</div><div class="gmail_default" style="font-family:monospace">javac -Xlint:all 
GUI.java</div><div class="gmail_default" style="font-family:monospace">```</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">When I compile, I get the following warning.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">```</div><div class="gmail_default" style="font-family:monospace">GUI.java:16: warning: [this-escape] possible 'this' escape before subclass is fully initialized<br>      this.frame.add(this.createBottomPanel());<br>                                           ^<br>GUI.java:28: warning: [this-escape] previous possible 'this' escape happens here via invocation<br>            actionEvent -><br>            ^<br>2 warnings</div><div class="gmail_default" style="font-family:monospace">```</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Can someone help me understand the what, why, and how of this warning? I don't understand it at all.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">I am pretty sure I understand the basic premise of "this-escape" -- a not-fully-initialized object (this) can "escape" from its constructor before completing initialization, usually causing bugs and security vulnerabilities.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">A good example of this is a constructor calling an overridable method. If a subclass overrides that method, it may expose the state or perform behaviour that it is not prepared to perform at that time, amongst other things.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">But I struggle to follow that logic for my example. Could someone walk me through this?</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Thank you for your time and help!</div><div class="gmail_default" style="font-family:monospace">David Alayachew<br></div></div>