title: How to instantiate a Java abstract class with a constructor parameter with a groovy closure
body: <p>I am trying to instantiate a Java abstract class from my Groovy code. Considering the following Java abstract class (non relevant processing is stripped out from the class):</p>
  
  <pre><code>public abstract class StackOverflow{
    public abstract String answerMe();
  }
  </code></pre>
  
  <p>I can easily instantiate it in Groovy this way, and the call to <code>answerMe()</code> will trigger the correct output:</p>
  
  <pre><code>StackOverflow stack = [answerMe : { "Answer" }] as StackOverflow
  </code></pre>
  
  <p>Now if I modify the <code>StackOverflow</code> class adding a String parameter in the constructor like this :</p>
  
  <pre><code>public abstract class StackOverflowStr{
    public StackOverflowStr(String s){}
    public abstract String answerMe();
  }
  </code></pre>
  
  <p>I don't really know how to instantiate my object, I tried a lot of thing, but I can't seem to find the right syntax, does someone got any clue ?</p>