i have following java class:
public class SHPObject {
public int nSHPType;
int nShapeId;
public int nParts;
int[] panPartStart;
int panPartType;
int nVertices;
double[] padfX;
double[] padfY;
public SHPObject(int nSHPType, int nParts, int[] panPartStart, double[] padfX, double[] padfY ){
this.nSHPType = nSHPType;
this.nParts = nParts;
this.panPartStart = panPartStart;
this.padfX = padfX;
this.padfY = padfY;
}
}
And i am trying to create object of this class in c++. This is my code for this:
jclass shpObjectClass = env->FindClass("com/example/kaczor/tmc_shpreader/Shape/Shapes/SHPObject");
jmethodID shpObjectConstructor = env->GetMethodID(shpObjectClass, "<init>", "(II[I[D[D)V");
jobject recognition_result;
SHPObject* a = new SHPObject[nEntities];
for(i = 0; i < nEntities; i++){
a[i] = *SHPReadObject(handle,i);
recognition_result = env->NewObject(
shpObjectClass, shpObjectConstructor, a[i].nSHPType, a[i].nParts, *a[i].panPartStart, *a[i].padfX, *a[i].padfY);
...
}
Sadly when executing this code my application close. Although when i change my constructor in java, and method signature in c++ to:
public SHPObject(int nSHPType, int nParts, int[] panPartStart)
methodID shpObjectConstructor = env->GetMethodID(shpObjectClass, "<init>", "(II[I)V");
everything work fine. So there is some problem in passing double[] variables. I cant figure out what is wrong. This is part of stack trace after executing this code (not really sure what part of it i should give, i dont notice anything refering to an error):
06-19 17:23:08.876 728-728/com.example.kaczor.tmc_shpreader W/dalvikvm:
Invalid indirect reference 0xbcad9adc in decodeIndirectRef
06-19 17:23:08.876 728-728/com.example.kaczor.tmc_shpreader E/dalvikvm: VM
aborting
06-19 17:23:08.906 728-728/com.example.kaczor.tmc_shpreader A/libc: Fatal
signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 728 (r.tmc_shpreader)
[...]
Edit: C++ SHPObject definition can be find at: http://shapelib.maptools.org/shp_api.html
doubleis the same size as the JNI defined typejdouble? See: docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/…