<p>This question have been answered by <a href="https://arxiv.org/pdf/1605.05274.pdf" rel="nofollow noreferrer">R.Grigore(2016)</a> in his paper <em>Java Generics are Turing Complete</em></p>
<p>Take the following Java code as an example to his suggestion:</p>
<pre><code>//an empty interface
interface Z {}

//4 generic interfaces, one argument each
interface N&lt;X&gt; {}
interface L&lt;X&gt; {}
interface Qlr&lt;X&gt; {}
interface Qrl&lt;X&gt; {}

//one complex generic, inheriting from instantiations of two other
interface E&lt;X&gt; extends
    Qlr&lt;N&lt;? super Qr&lt;? super E&lt;? super E&lt;? super X&gt;&gt;&gt;&gt;&gt;,
    Qrl&lt;N&lt;?super Ql&lt;? super E&lt;? super E&lt;? super X&gt;&gt;&gt;&gt;&gt;
    {}

//main class with a single function
class Main{
    //heavily nested return type
    L&lt;? super N&lt;? super L&lt;? super N&lt;? super L&lt;? super N&lt;? super E&lt;? super E&lt;? super Z&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
    f(Qr&lt;? super E&lt;? super E&lt;? super Z&gt;&gt;&gt; v) {return v;}
}
</code></pre>
When does Java type inference produce an infinite type?
<p>The JLS mentions in the type inference algorithm (§15.12.2):</p>

<blockquote>
  <p>It is possible that the process above yields an infinite type. This is permissible,
  and Java compilers must recognize such situations and represent them appropriately using cyclic data structures.</p>
</blockquote>

<p>However, I'm unable to find an actual example where javac produces an infinite type.
I think it ought to produce one in the following case:</p>

<pre><code>&lt;T&gt; T pick(T a, T b) { ... }

pick("string", 3);
</code></pre>

<p>Both String and Integer are Comparable&lt;themselve>, so their common supertype should be <code>Comparable&lt;? extends Comparable&lt;? extends Comparable&lt;? ...&gt;&gt;&gt;</code> (infinite).</p>

<p>I can do:</p>

<pre><code>Comparable&lt;? extends Comparable&lt;?&gt;&gt; x = pick("string", 3);
</code></pre>

<p>but then I tried:</p>

<pre><code>Comparable&lt;? extends Comparable&lt;? extends Comparable&lt;?&gt;&gt;&gt; x = pick("string", 3);
</code></pre>

<p>and this doesn't compile.
It seems that the recursion is aborted after 2 steps.</p>

<p>Do you know of any case to make Java actually produce an infinite type?</p>

<p>--</p>

<p>Edit: it seems that the above is a compiler bug. Reading the specification, let's see how the calculation of <code>lub(String, Integer)</code> works out:</p>

<pre><code>ST(String) = { String, Comparable&lt;String&gt;, Serializable, CharSequence, Object }
ST(Integer) = { Integer, Comparable&lt;Integer&gt;, Serializable, Number, Object }
EC = { Comparable, Serializable, Object }
MEC = { Comparable, Serializable }
Inv(Comparable) = { Comparable&lt;String&gt;, Comparable&lt;Integer&gt; }
lcta(String, Integer) = ? extends lub(String, Integer)
lci(Inv(Comparable)) = Comparable&lt;? extends lub(String, Integer)&gt;
lub(String, Integer) = Serializable &amp; Comparable&lt;? extends lub(String, Integer)&gt;
</code></pre>

<p>So <code>lub(String, Integer)</code> should be an infinite type. Javac seems to be wrong here. Maybe it doesn't implement infinite types after all?</p>