Java中的JNI映射结构 [英] JNI mapping structure in java

查看:55
本文介绍了Java中的JNI映射结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个dll,其中包含例如void abc(meth* myMeth)的方法和结构

I have a dll which has a method for e.g void abc(meth* myMeth) and a structure

struct meth
{
  int a;
  char b[255]; 
} 

上面的代码是用c编写的.我需要通过JNI将此映射到Java,但我遇到了麻烦.如何将对方法abc的引用作为指针从Java方法传递给我,如何设置ab的值,然后再次传递回Java? 需要紧急帮助....谢谢

The above code code is written in c. I need to map this to Java through JNI, and I am stuck. How can I pass a reference to the method abc as a pointer from a Java method, and how can I set the values of a and b and then pass back to Java again? Need An Urgent Help....Thanks

推荐答案

我不知道这是否适合您,但是请考虑使用一些更高级别的框架来管理低级别的详细信息JNI为您服务.两种选择:

I do not know if this is an option for you, but consider using some higher level framework for managing the low-level details of JNI for you. Two options:

  • JNAerator, see also "Structs" chapter in reference documentation.
  • SWIG, see also "Structures and unions" chapter in reference documentation.

我个人使用过JNAerator并发现它真的很有帮助.

Personally I have used JNAerator and found it really helpful.

这篇关于Java中的JNI映射结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆