Java类型 | 本地类型 | JNI中定义的别名 |
int | long | jint |
long | _int64 | jlong |
byte | signed char | jbyte |
boolean | unsigned char | jboolean |
char | unsigned short | jchar |
short | short | jshort |
float | float | jfloat |
double | double | jdouble |
Object | _jobject* | jobject |
jclass cls = (*env)->FindClass(env, "Lpackagename/classname;"); //创建一个class的引用
jmethodID id = (*env)->GetMethodID(env, cls, "", "(D)V"); //注意这里方法的名称是"",它表示这是一个构造函数,而且构造参数是double型的
jobject obj = (*env)->NewObjectA(env, cls, id, args); //获得一实例,args是构造函数的参数,它是一个jvalue*类型。
类型 | 符号 |
boolean | Z |
byte | B |
char | C |
short | S |
int | I |
long | L |
float | F |
double | D |
void | V |
object对象 | LClassName; L类名; |
Arrays | [array-type [数组类型 |
methods方法 | (argument-types)return-type (参数类型)返回类型 |
参考资料:
http://www.importnew.com/8038.html
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/index.html
http://wiki.jikexueyuan.com/project/jni-ndk-developer-guide/string.html
http://blog.csdn.net/xyang81/article/details/42582213
http://blog.csdn.net/xyang81/article/details/42582213
http://stackvoid.com/HashCode-in-Java/
来源:oschina
链接:https://my.oschina.net/u/2433273/blog/512385