title: Self-referential Generic Types
body: <p>Consider this example:</p>
  
  <pre><code>public final class Main&lt;T extends Main&lt;T&gt;&gt; {
  
      public static void main(String[] args) {
          Main&lt;?&gt; main = new Main&lt;&gt;();
      }
  }
  </code></pre>
  
  <p>This compiles perfectly. However when I try to make this compile without using the diamond, the only way I can get it to work is by using a raw type. </p>
  
  <pre><code>Main&lt;?&gt; main = new Main();    
  </code></pre>
  
  <p>Attempts without raw types don't work:</p>
  
  <pre><code>Main&lt;?&gt; main = new Main&lt;?&gt;();              // None of
  Main&lt;?&gt; main = new Main&lt;Main&lt;?&gt;&gt;();        // these
  Main&lt;?&gt; main = new Main&lt;Main&lt;Main&lt;?&gt;&gt;&gt;();  // compile
  </code></pre>
  
  <p>So why does the original version with the diamond work? What is the inferred type when you write <code>Main&lt;?&gt; main = new Main&lt;&gt;();</code> ?</p>
  
  <p>Is it inferring a raw type, or is it inferring some kind of infinitely nested type like this?</p>
  
  <pre><code>Main&lt;Main&lt;Main&lt;Main&lt;...&gt;&gt;&gt;&gt;
  </code></pre>