title: Alternative to org.easymock.EasyMock.capture in Java 8 to 11
body: <p>I'm trying to capture values in my test</p>
  
  <pre><code>...
  final Capture&lt;MyDTO&gt; myDTOCaptured = new Capture&lt;MyDTO&gt;();
  
  EasyMock.expect(this.serviceMock.execute(capture(myDTOCaptured)).andReturn(someResult);
  ...
  </code></pre>
  
  <p>The Documentation says:</p>
  
  <p><strong>Deprecated API</strong></p>
  
  <blockquote>
    <p>org.easymock.EasyMock.capture(Capture)
              Because of harder erasure enforcement, doesn't compile in Java 7</p>
  </blockquote>
  
  <p><a href="http://easymock.sourceforge.net/api/easymock/3.1/deprecated-list.html" rel="nofollow noreferrer">http://easymock.sourceforge.net/api/easymock/3.1/deprecated-list.html</a></p>
  
  <p>Version 3.1 is the version we are using.</p>
  
  <p>Is there any alternative for capture in Java 8+? I guess the alternative is upgrading the version.</p>