title: Unspecified type parameter when calling generic method
body: <p>Imagine we have the following generic class:</p>
  
  <pre><code>public class GenericClass&lt;U&gt; {
      private U value;
  
      public GenericClass(U value) {
          this.value = value;
      }
  }
  </code></pre>
  
  <p>and the following generic method in some other class MyClass:</p>
  
  <pre><code>public &lt;T extends BT, BT&gt; void genericMethod(T arg) {
      Object genericClass = new GenericClass&lt;BT&gt;(arg);
  }
  </code></pre>
  
  <p>Which value will BT type parameter obtain if we call</p>
  
  <pre><code>genericMethod("text");
  </code></pre>
  
  <p>?</p>
  
  <p><strong>Some notes:</strong></p>
  
  <p>The above code compiles without errors or warnings, which seems strange for me.
  Decompiling (by means of IntelliJ IDEA 2016) shows the following code:</p>
  
  <pre><code>public &lt;T extends BT, BT&gt; void genericMethod(T arg) {
      new MyClass.GenericClass(arg);
  }
  </code></pre>
  
  <p>Notice that new <code>GenericClass&lt;BT&gt;(arg)</code> is not the same as <code>new GenericClass(arg)</code> because the latter is equivalent of <code>new GenericClass&lt;T&gt;(arg)</code> (type deduction), and although <code>T extends BT</code>, these are <strong>different</strong> types, and <code>GenericClass</code> may have internal logic where the <em>exact type name</em> plays an important role (e.g. is used as a string key in some map etc). So for me it is strange why the compiler silently uses type deduction instead of producing some warning (or maybe even error) stating that BT type parameter is not specified. Maybe I'm missing smth. important about generics in Java, however...</p>