vendredi 8 mai 2015

Scala ClassTags in Java

I have been working with a Jar file that is being used in a Scala and Java Project. In Scala, the function signature is: func[T](ByteBuffer b, ClassLoader l). I have been invoking the function in my scala program like this:

func[(Foo[Int], (Iterator[Int]) => Option[Int] )](
      ByteBuffer.wrap(byteArray), Thread.currentThread.getContextClassLoader)

When I try to use it in Java, the required function signature changes to the following: func(ByteBuffer b, ClassLoader l, ClassTag<T> c). I'm not sure how exactly I am supposed to invoke this function. First of all, I am not sure how to instantiate the ClassTag. Another problem I have is that I do not know how to represent (Foo[Int], (Iterator[Int]) => Option[Int] ) as T within the ClassTag.

I would greatly appreciate some help on how to approach this.





Aucun commentaire:

Enregistrer un commentaire