Type variance and third party libraries (GigaspaceS)

Dear all,
I am trying to wrap some third party library around a dsl, however I am falling into some variance problem.


class QueryBuilder(val space:GigaSpace) {
  def query[T](klass:Class[T],whereClause:QueryNode):Array[T with java.lang.Object] = {
    val query = new SQLQuery[T](klass,whereClause.toString);
    space.readMultiple(query,Integer.MAX_VALUE);
  }

}

Does not compile, while the equivalent java code compiles. This is the error.

error: type mismatch;
found   : com.j_spaces.core.client.SQLQuery[T]
required: com.gigaspaces.query.ISpaceQuery[Nothing]
Note: T >: Nothing, but Java-defined trait ISpaceQuery is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: Nothing`. (SLS 3.2.10)
space.readMultiple(query,Integer.MAX_VALUE);

Can you please help me?

Best Regards
Edmondo

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland