Pass scala function as java functional interface argument
<p>I have a java constructor which takes a functional interface as a parameter:</p>

<pre><code>public ConsumerService(QueueName queue, Consumer&lt;T&gt; function) {
    super(queue);
    this.function = function;
}
</code></pre>

<p>I'm trying to use this constructor in scala but the compiler complains, saying it cannot resolve the constructor. I've tried the following ways:</p>

<pre><code>val consumer = new ConsumerService[String](QueueName.CONSUME, this.process _)
val consumer = new ConsumerService[String](QueueName.PRODUCE, (s: String) =&gt; this.process(s))
</code></pre>

<p>I've also tried to cast the function at runtime - but that leaves me with a ClassCastException:</p>

<pre><code>val consumer = new ConsumerService[String](QueueName.CONSUME, (this.process _).asInstanceOf[Consumer[String]])
</code></pre>

<p>How can I pass a scala function as a java functional interface parameter?</p>