I have a Java / Scala mix Maven project. I need to reuse a Saddle method make
that is concretely defined as part of a trait called Index
. The method is defined here if that helps in any way. I have tried calling that method from java using Index.make
or Index$class.make
but in both cases I get the error: cannot find symbol
compilation error.
Is there a way to call a concrete Trait method from Java?
A
trait
is similar to a Java interface in a sense that it is not a concrete constructor.From Scala:
Or use an object:
From Java:
Traits with concrete implementations will compile to the appropriate
abstract class
. If certain members don't have concrete implementation, you have to implement them.OK I found the answer. Calling it like this works but only because the Index trait already has an Index object available (that I didn't notice before):