We need to pass an x10 arraylist[string] to a Java method as an object. What we tried is this.The method signature in Java interface is as follows.
public void getX10ArrayList ( ArrayList <String > nameList):
We implement that method inside an X10 class as follows.
public def getX10ArrayList ( var names : ArrayList [String] ) {
// do something
}
We get a compile error saying interface expected an object of type x10.util.ArrayList
but we are sending an object of type x10.util.ArrayList
[ x10.lang.String]`.
Unfortunately, the current X10 type system doesn't allow an X10 class to implement a parameterized Java interface. Although it looks like the right solution is to define the interface as @Darpan suggests:
when the Java interface is type-checked, the type parameter is erased from the X10 interface and so the types are different. Details of the translation from X10 to Java classes can be found in the paper Compiling X10 to Java (Takeuchi et al. 2011).
One possible workaround is to wrap the generic class in a non-parametrized type. For example: