title: Java 8 lambda and extension of interfaces with abstract class
body: <p>Say I want to declare Spring's <code>RowMapper</code>, but not create a dynamic class, but implement an abstract class which implements RowMapper. This is my method signature:</p>
  
  <pre><code>SqlProcedure#declareRowMapper(RowMapper&lt;?&gt; rowMapper);
  </code></pre>
  
  <p>CustomRowMapper.java:</p>
  
  <pre><code>public abstract class CustomRowMapper&lt;T&gt; implements RowMapper&lt;T&gt; {
      protected A a = new A();
  }
  </code></pre>
  
  <p>The old Java way would be to write:</p>
  
  <pre><code>sqlProc.declareRowMapper(new CustomRowMapper&lt;Object&gt;() {
      @Override
      public Object mapRow(ResultSet rs, int rowNum) {
          a.doSomething(rs, rowNum);
          return new Object();
      }
  });
  </code></pre>
  
  <p>Is it possible to achieve the same thing with lambda expressions? I would like to do something like this:</p>
  
  <pre><code>sqlProc.declareRowMapper((rs, rowNum) -&gt; {
      a.doSomething(rs, rowNum);
      return new Object();
  });
  </code></pre>
  
  <p>But then I would get a compile error saying <code>a cannot be resolved</code>. It's because Java sees this as an implementation of the <code>RowMapper#mapRow</code> method, not <code>CustomRowMapper#mapRow</code>. </p>
  
  <p>How do I tell Java to use my CustomRowMapper instead of RowMapper via lambda expressions? Is this even possible?</p>