Scala: Problems use java interfaces -


i wanted use jemmyfx framework, written in java, in scala. there several problems cannot solve.

in java, if wanted search label wrapper, can in way:

wrap<? extends label> label = root.root.lookup().wrap().as(parent.class, node.class).lookup(label.class).wrap(); 

if want in scala, no working solution. have tried in way:

val label: wrap[_<:label] = root.root.lookup().wrap().as(classof[parent[_<:label]], classof[node]).lookup(classof[label]).wrap() 

but scala tells me: - inferred type arguments [javafx.scene.node,org.jemmy.interfaces.parent[_ <: javafx.scene.control.label]] not conform method as's type parameter bounds

 [type,interface <: org.jemmy.interfaces.typecontrolinterface[type]] 

the method "as":

public <type, interface extends typecontrolinterface<type>> interface as(class<interface> interfaceclass, class<type> type) 

the method "lookup":

public abstract <st extends t> lookup<st> lookup(class<st> paramclass); 

the class "parent":

public abstract interface parent<t> extends typecontrolinterface<t> 

so don't it, how can use these interfaces in scala. there solution, or there limitations of use between scala , java?

i know nothing jemmyfx, here's 2 cents. it's not interoperability issue between scala , java. it's issue of correctly typing call as method.

the as method signature says [type, interface <: typecontrolinterface[type]] means interface type must parametrized same type type. because of this, cannot use classof[parent[label]] in first argument , classof[node] in second argument: must use either node or label twice.

i've tried reproduce issue following scala code:

trait typecontrolinterface[t] trait parent[t] extends typecontrolinterface[t]  trait node case class label(s: string) extends node  object test {   def as[type, interface <: typecontrolinterface[type]](interfaceclass: class[interface], typeclass: class[type]): interface = ???    def main(args: array[string]) {     val label1 = as(classof[parent[label]], classof[label]) // compiles     val label2 = as(classof[parent[node]], classof[node]) // compiles     val label3 = as(classof[parent[label]], classof[node]) // doesn't compile   } } 

note if as method had been defined this:

def as[type, interface <: typecontrolinterface[_ <: type]](...) 

the last line in example above have compiled.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -