A
Arne
Hi-
I have a question regarding JNI. I am trying to call a method in an
inner class from C++. Have been hunting around a bit, but am very
confused. With the following Java code and javap -s I don't get the
inner class's methods (regardless of whether I make the inner class
static or not):
public class Caller {
int x = 0;
public static class Inner {
int y = 0;
public int get() {
return y;
}
}
}
javap -s Caller gives:
public class Caller extends java.lang.Object{
int x;
Signature: I
public Caller();
Signature: ()V
}
(ditto when I call javap -s Caller$Inner btw).
Now when in my code snippet I try to call the get() method like this
(deducing the method signature):
jclass jcls = env->FindClass("Caller$Inner");
jmethodID jm = env->GetMethodID(jcls, "<init>", "()V");
jobject jobj = env->NewObject(jcls, jm);
jm = env->GetStaticMethodID(jcls, "get", "V(I)");
jint jnt = env->CallIntMethod(jobj, jm);
The call to GetStaticMethodID fails with
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (0xb) at pc=0xb79721cb, pid=16424, tid=3074430656
#
# Java VM: Java HotSpot(TM) Server VM (1.5.0_16-b02 mixed mode)
# Problematic frame:
# V [libjvm.so+0x2bf1cb]
#
# An error report file with more information is saved as
hs_err_pid16424.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Any ideas? This seems very broken to me, as javap isn't even finding
the inner class's get method.
Many thanks
I have a question regarding JNI. I am trying to call a method in an
inner class from C++. Have been hunting around a bit, but am very
confused. With the following Java code and javap -s I don't get the
inner class's methods (regardless of whether I make the inner class
static or not):
public class Caller {
int x = 0;
public static class Inner {
int y = 0;
public int get() {
return y;
}
}
}
javap -s Caller gives:
public class Caller extends java.lang.Object{
int x;
Signature: I
public Caller();
Signature: ()V
}
(ditto when I call javap -s Caller$Inner btw).
Now when in my code snippet I try to call the get() method like this
(deducing the method signature):
jclass jcls = env->FindClass("Caller$Inner");
jmethodID jm = env->GetMethodID(jcls, "<init>", "()V");
jobject jobj = env->NewObject(jcls, jm);
jm = env->GetStaticMethodID(jcls, "get", "V(I)");
jint jnt = env->CallIntMethod(jobj, jm);
The call to GetStaticMethodID fails with
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (0xb) at pc=0xb79721cb, pid=16424, tid=3074430656
#
# Java VM: Java HotSpot(TM) Server VM (1.5.0_16-b02 mixed mode)
# Problematic frame:
# V [libjvm.so+0x2bf1cb]
#
# An error report file with more information is saved as
hs_err_pid16424.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Any ideas? This seems very broken to me, as javap isn't even finding
the inner class's get method.
Many thanks