⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fieldaccesslibrary.cpp

📁 < Professional Java,JDK 5 Edition> 经典例程源代码。
💻 CPP
字号:
// FieldAccessLibrary.cpp : Defines the entry point for the DLL application.
//

#include "FieldAccessExample.h"

#include <stdio.h>
extern "C"
JNIEXPORT void JNICALL Java_FieldAccessExample_transformPoint
  (JNIEnv *env, jobject obj, jobject thePoint)
{
    jfieldID x_id, y_id, z_id;
    jint x_value, y_value, z_value;
    jclass cls;

    cls = env->GetObjectClass(thePoint);

    x_id = env->GetFieldID(cls, "x", "I");
    y_id = env->GetFieldID(cls, "y", "I");
    z_id = env->GetFieldID(cls, "z", "I");

    x_value = env->GetIntField(thePoint, x_id);
    y_value = env->GetIntField(thePoint, y_id);
    z_value = env->GetIntField(thePoint, z_id);

    x_value = x_value;
    y_value = 10*y_value + 5;
    z_value = 30*z_value + 2;

    env->SetIntField(thePoint, x_id, x_value);
    env->SetIntField(thePoint, y_id, y_value);
    env->SetIntField(thePoint, z_id, z_value);
}

/*BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}

*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -