title: Java: how to resolve generic type of lambda parameter?
body: <p>Well, we have <code>FunctionalInterface</code>:</p>
  
  <pre><code>public interface Consumer&lt;T&gt; {
  
      void accept(T t);
  
  }
  </code></pre>
  
  <p>And I can use it like:</p>
  
  <pre><code>.handle(Integer p -&gt; System.out.println(p * 2));
  </code></pre>
  
  <p>How can we resolve the actual <code>generic type</code> of that lambda parameter in our code?</p>
  
  <p>When we use it as an inline implementation it isn't so difficult to extract the <code>Integer</code> from the method of that class.</p>
  
  <p>Do I miss anything? Or just java doesn't support it for lambda classes ?</p>
  
  <p>To be more cleaner:</p>
  
  <p>That lambda is wrapped with <code>MethodInvoker</code> (in the mentioned <code>handle</code>), which in its <code>execute(Message&lt;?&gt; message)</code> extracts actual parameters for further reflection method invocation. Before that it converts provided arguments to target params using Spring's <code>ConversionService</code>.</p>
  
  <p>The method <code>handle</code> in this case is some configurer before the real application work.</p>
  
  <p>The different question, but with expectation for the solution for the same issue: <a href="https://stackoverflow.com/questions/23865950/java-get-actual-type-of-generic-method-with-lambda-parameter">Java: get actual type of generic method with lambda parameter</a></p>