Thanks Serge. Couple of related questions,
1) If the native function is simply copying data in the memory (basically, putting the clone of the structure in the buffer) then is ExternalArrayPointer still the right type for this? Also, there is no cleanup function on the native side as they are not holding up to any memory space after the return.
2) In case of "
CustStringStruct " I want to get the ComplexArray so I can go over the elements in it,
public ComplexArray getElements(){
if (
bufferPtr .isNull()) {
return null;
} else {
bufferPtr .readArray((int) length.getValue());
return (ComplexArray)
bufferPtr .getReferencedObject();
}
}
but, this seem to failing - I'm getting stack dump pointing to this function,
Stack: [0x623e8000,0x62be9000], sp=0x62be7730, free space=8189k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x5ed9c9]
j sun.misc.Unsafe.getInt(J)I+0
j java.nio.DirectByteBuffer.getInt(J)I+10
j java.nio.DirectByteBuffer.getInt(I)I+11
j com.jniwrapper.g.readPointer(I)J+20
j com.jniwrapper.Pointer.readPointer(Lcom/jniwrapper/DataBuffer;I)V+2
j com.jniwrapper.Pointer.read(Lcom/jniwrapper/DataBuffer;IZ)V+3
j com.jniwrapper.ExternalArrayPointer.read(Lcom/jniwrapper/DataBuffer;IZ)V+9
j com.jniwrapper.bg.doPointerIO(Lcom/jniwrapper/Pointer;Lcom/jniwrapper/DataBuffer;IZ)V+5
j com.jniwrapper.Pointer.acceptIOPerformer(Lcom/jniwrapper/IOPerformer;Lcom/jniwrapper/DataBuffer;IZZ)V+6
j com.jniwrapper.Structure.acceptIOPerformer(Lcom/jniwrapper/IOPerformer;Lcom/jniwrapper/DataBuffer;IZZ)V+54
j com.jniwrapper.Structure.acceptIOPerformer(Lcom/jniwrapper/IOPerformer;Lcom/jniwrapper/DataBuffer;IZZ)V+54
j com.jniwrapper.ComplexArray.acceptIOPerformer(Lcom/jniwrapper/IOPerformer;Lcom/jniwrapper/DataBuffer;IZZ)V+20
j com.jniwrapper.Pointer.readReferencedObject(Z)V+21
j com.jniwrapper.ExternalArrayPointer.readArray(I)V+61
j com.xx.xx.
getElements()Lcom/jniwrapper/ComplexArray;+24
How do I get the elements from the ComplexArray?
Thanks,
-vivek