📄 localreflibrary.cpp
字号:
// LocalRefLibrary.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "../LocalRefExample.h"
JNIEXPORT void JNICALL Java_LocalRefExample_testLocalRefs
(JNIEnv *env, jobject obj)
{
jint count;
// Let's figure out just how many local references
// we can create...
for(count=16; count<10000; count++) {
if(env->EnsureLocalCapacity(count+1)) {
break;
}
}
printf("I can create up to %d local references\n", count);
// Now let's create a few...
jcharArray charArray;
jintArray intArray;
jstring str;
str = env->NewStringUTF("This is a test");
if(env->PushLocalFrame(10)) {
charArray = env->NewCharArray(13);
if(charArray == NULL) {
printf("Failed to create character array\n");
return;
}
if(env->PushLocalFrame(10)) {
intArray = env->NewIntArray(14);
if(intArray == NULL) {
printf("Failed to create integer array\n");
return;
}
// intArray created. Use PopLocalFrame to free all allocated
// references in this scope level, in this case just intArray
env->PopLocalFrame(NULL);
}
// charArray created. Use PopLocalFrame to free all allocated
// references in this scope level, in this case just charArray
env->PopLocalFrame(NULL);
}
// 'str' is freed after this function exits
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -