Programming the whole day makes you crazy (and silly, at least to me), I was passing from java code an array of LOCAL mat addresses (long[] created using the function getNativeObjAddr() which return the address in memory of the mat), so It wasn't going to work...
I solved it by creating a long array as a class field and passing this array.