I figured out why it was happening - I was passing in my input parameters as java types and assuming that they would be converted.
If I do the conversion myself then the I get a sensible return value that I can access using ((MWNumbericArray)retVal[0]).getDouble()