This page is no longer maintained — Please continue to the home page at

Type variance and third party libraries (GigaspaceS)

No replies
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
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);


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)

Can you please help me?

Best Regards

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