Enhanced to return a result from Java slave.