I have assigned jvm to global variable in a function using
int status = (*jenv)->GetJavaVM(jenv, &jvm);
if(status != 0) {
printf(" Fail!\n");
}
classNameC is a global variable, and its class has no constructor.Then in other function, i am using it like this:
JNIEnv *env;
printf("starting function\n");
(*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
printf("thread attached\n");
jclass local = (*env)->FindClass(env,classNameC);
if(local!=NULL)
{
printf("1st class found\n");
}
jmethodID constructor=(*env)->GetMethodID(env,local,"<init>","()V");
if(constructor==NULL)
{
printf("1st Constructoris NULL\n");
}
else
{
printf("1st Constructor created\n");
}
jobject classObject=(*env)->NewObject(env,local,constructor);
if(classObject==NULL)
{
printf("1st object is NULL\n");
}
else
{
printf("1st object is created\n");
}
jclass local1 = (*env)->FindClass(env,"SWIGTYPE_p_void");
if(local1==NULL)
{
printf("SWIGTYPE p void class is NULL\n");
}
else
{
printf("SWIGTYPE p void class created\n");
}
This constructor has 2 parametrs one is long and next is boolean. This class has 2 constructors other one has no parameters and initializing members with 0.
jmethodID constructor1=(*env)->GetMethodID(env,local1,"<init>","(J;Z;)V");
if(constructor1==NULL)
{
printf("SWIGTYPE p void constructor is NULL\n");
}
else
{
printf("SWIGTYPE p void constructor is created\n");
}
when i run it, it successfully printed upto SWIGTYPE p void class created and SWIGTYPE p void constructor is NULL and then it gave this error:
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007f7ec503fa7b, pid=25307, tid=140182441326336
JRE version: Java(TM) SE Runtime Environment (7.0_65-b17) (build 1.7.0_65-b17) Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode linux-amd64 compressed oops) Problematic frame: V [libjvm.so+0x657a7b] JNI_ArgumentPusherVaArg::JNI_ArgumentPusherVaArg(_jmethodID*, __va_list_tag*)+0x1b
Core dump written. Default location: /home/manish/rathi/libdmc/dmcore/include/core or core.25307
An error report file with more information is saved as: /home/manish/rathi/libdmc/dmcore/include/hs_err_pid25307.log
If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jspAborted (core dumped)
You find constructor
method ID; but you claim that this class has no constructor. This means, that GetMethodID(env,local,"<init>","(V)V")
will return 0. To specify a signature for a method with no parameters, use "()V"
.