I have a Scala class whose constructor takes a variable-length parameter list.
case class ItemChain(items: Item*)
From Scala it can be called like so
ItemChain(Item(), Item())
I can't figure out the syntax for calling it from Java. If I do this
new ItemChain(new Item(), new Item())
I get a compiler error that says this line does not match the signature scala.collection.seq<Item>.
I can directly instantiate the Scala sequence object from Java.
new scala.collection.Seq<Item>()
But I can't figure out how to subsequently add my two Item instances to it. If I create a Java List of Items and cast it toscala.collection.Seq I get a runtime error.
@scala.annotation.varargscan usually help in situations like this, but not for constructors, and apparently not forItemChain.apply, although you don't get an error if you put it in from of the case class definition (which is a little surprising to me). Put it on acreatemethod in the companion object and you should be good to go, though.