M
MQ.john
Here is the class with instance method
public class NativeGrab {
private native void hello(String str);
private void cbhello(String str){
System.out.println(str);
}
/**
* @param argsdd
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
NativeGrab h = new NativeGrab();
h.hello("asdf");
}
static{
System.loadLibrary("hello");
}
}
the jvm always crushed with message like this.
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x06245d02, pid=25430, tid=3084721040
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b23 mixed mode, sharing
linux-x86)
# Problematic frame:
# V [libjvm.so+0x245d02]
#
# An error report file with more information is saved as:
# /home/john/share/hs_err_pid25430.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
If I changed the instance method cbhello to static,
GetMethodID to GetStaticMethodID
CallVoidMethod to CallStaticVoidMethod
it just works fine.
call instance method from native function doesn't work. how come??
public class NativeGrab {
private native void hello(String str);
private void cbhello(String str){
System.out.println(str);
}
/**
* @param argsdd
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
NativeGrab h = new NativeGrab();
h.hello("asdf");
}
static{
System.loadLibrary("hello");
}
}
the jvm always crushed with message like this.
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x06245d02, pid=25430, tid=3084721040
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b23 mixed mode, sharing
linux-x86)
# Problematic frame:
# V [libjvm.so+0x245d02]
#
# An error report file with more information is saved as:
# /home/john/share/hs_err_pid25430.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
If I changed the instance method cbhello to static,
GetMethodID to GetStaticMethodID
CallVoidMethod to CallStaticVoidMethod
it just works fine.
call instance method from native function doesn't work. how come??