JNI - PASS ARGUMENT. ObjectARRAY
来源:互联网 发布:c语言复制字符串函数 编辑:程序博客网 时间:2024/06/10 16:17
.java file
class ObjectArrayTest{private static native int[][] initInt2DArray(int size);public static void main(String[] args){int[][] i2arr = initInt2DArray(3);for (int i=0;i<3;i++){for (int j=0;j<3;j++){System.out.print(" " + i2arr[i][j]);}System.out.println();}}static {System.loadLibrary("ObjectArrayTest");}}
.c file
#include <jni.h>#include <stdio.h>#include "ObjectArrayTest.h"JNIEXPORT jobjectArray JNICALL Java_ObjectArrayTest_initInt2DArray (JNIEnv *env, jclass cls, jint size){jobjectArray result;int i;//FindClass is to obtain a reference of the element class of the two-dimensinal int array. // "[I" corresponds to int[] type//jclass intArrCls = int[]jclass intArrCls = (*env)->FindClass(env,"[I");if (intArrCls == NULL){return NULL;}//allocate the 1st dimension.//It's an array of intArrCls.//It's an array of int[]result = (*env)->NewObjectArray(env,size,intArrCls,NULL);if (result == NULL){return NULL;}for (i = 0;i < size;i++){jint tmp[256];int j;jintArray iarr = (*env)->NewIntArray(env,size);if (iarr == NULL){return NULL;}for (j=0;j<size;j++){tmp[j] = i+ j;}//set iarr[0..size] to temp(*env)->SetIntArrayRegion(env, iarr, 0, size, tmp);//set the i-th element of result to be iarr(*env)->SetObjectArrayElement(env, result, i, iarr);//Delete iarr.(*env)->DeleteLocalRef(env,iarr);}return result;}
0 0
- JNI - PASS ARGUMENT. ObjectARRAY
- JNI - PASS ARGUMENT. string
- JNI - PASS ARGUMENT. array
- pass variable-argument list
- about javascript function setInterval pass parameter at first argument
- How to pass an argument to a PowerShell script?
- 对象数组 ObjectArray
- Pass
- Pass
- pass
- Warning: Call-time pass-by-reference has been deprecated - argument passed by value
- jni编译时出现:warning: format '%d' expects argument of type 'int', but argument 4 has
- argument
- jni工程出现 non-numeric second argument to `wordlist' function
- jni编译non-numeric second argument to `wordlist' function错误
- 解决jni项目编译生成so时报错"argument list too long"
- js中argument argument
- PASS UAC
- 深入浅出UML类图(三)
- Kernel SVD(核函数+奇异值分解)
- 对Linux内核中进程上下文和中断上下文的理解
- git 加 sourcetree
- postgresql duplicate key violates unique constraint
- JNI - PASS ARGUMENT. ObjectARRAY
- mybatis collection高级映射 一对多管理查询只能查询出一条
- hive partion 键 关联(join)其他表
- 深入浅出UML类图(四)
- Android 学习记录-获取天气API
- Java 基础面试 每日一点Java源文件(*.java)——>Java编译器——>字节码文件(*.class)——>类装载器——>字节码校检器—— >解释器——>操作系统(Windows、Linux
- java汉字中首字母排序
- JSON详解
- UVa 10006 Carmichael Numbers (快速幂运算)