title: Leaking this in constructor warning
body: <p>I'd like to avoid (most of the) warnings of Netbeans 6.9.1, and I have a problem with the <code>'Leaking this in constructor'</code> warning.</p>
  
  <p>I understand the problem, calling a method in the constructor and passing "<code>this</code>" is dangerous, since "<code>this</code>" may not have been fully initialized.</p>
  
  <p>It was easy to fix the warning in my singleton classes, because the constructor is private and only called from the same class.</p>
  
  <p>Old code (simplified):</p>
  
  <pre><code>private Singleton() {
    ...
    addWindowFocusListener(this);
  }
  
  public static Singleton getInstance() {
  
    ...
    instance = new Singleton();
    ...
  }
  </code></pre>
  
  <p>New code (simplified):</p>
  
  <pre><code>private Singleton() {
    ...
  }
  
  public static Singleton getInstance() {
  
    ...
    instance = new Singleton();
    addWindowFocusListener( instance );
    ...
  }
  </code></pre>
  
  <p>This fix is not working if the constructor is public and can be called from other classes. How is it possible to fix the following code:</p>
  
  <pre><code>public class MyClass {
  
    ...
    List&lt;MyClass&gt; instances = new ArrayList&lt;MyClass&gt;();
    ...
  
    public MyClass() {
      ...
      instances.add(this);
    }
  
  }
  </code></pre>
  
  <p>Of course I want a fix which does not require to modify all my codes using this class ( by calling an init method for instance).</p>