implicit declaration of function ‘NewByteArray’
Хочу проверить будет ли освобождать в java память, выделенную в си или c++. Как я понял что надо использовать функцию NewByteArray, и она есть в jni.h. Но почему то компилятор пишет что неизвестная функция. Вот код jni.
#include <stdlib.h>
#include "Main.h"
JNIEXPORT jbyteArray JNICALL Java_Main_get_1byte ( JNIEnv *env, jobject obj ) {
jbyteArray test = NewByteArray ( env, 255 );
return test;
}
Вот код Main.
1 import java.io.*;
2
3 class Main {
4 private native byte[] get_byte();
5
6 public static void main ( String[] args ) {
7
8 Console cons = System.console();
9 String pwd;
10 while ( true ) {
11 pwd = cons.readLine ( );
12 byte[] test = new Main().get_byte ( );
13
14 pwd = cons.readLine ( );
15 test[0] = '1';
16 System.out.println ( "Новый цикл." );
17
18 }
19 }
20
21 static {
22 System.loadLibrary ( "Main" );
23 }
24 }