title: Generic type of local variable at runtime
body: <p>Is there a way in Java to reflect a generic type of a local variable? I know you sould to that with a field - <a href="https://stackoverflow.com/questions/1942644/get-generic-type-of-java-util-list">Get generic type of java.util.List</a>. Any idea how to solve, for instance:</p>
  
  <pre><code>public void foo(List&lt;String&gt; s){
    //reflect s somehow to get String
  }
  </code></pre>
  
  <p>Or even more general:</p>
  
  <pre><code>public void foo&lt;T&gt;(List&lt;T&gt; s){
    //reflect s somehow to get T
  }
  </code></pre>