在本机库中找到公开的方法以通过JNA/JNI进行访问? [英] Finding exposed methods in native libraries to access over JNA / JNI?

查看:93
本文介绍了在本机库中找到公开的方法以通过JNA/JNI进行访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好:我想使用JNA来访问本机库中的某些函数.

Hi : I wanted to use JNA to access some functions in a native library.

1)我如何内省本机库文件(例如.so文件)以查看可用的方法?

1) How can i introspect the native library files (.so files, for example) to see what methods are available ?

2).so文件中可访问的方法与用于编译这些文件的C代码之间是否存在一一对应的映射?

2) Is there a one-one mapping between the methods accessible in .so files and the C code built to compile those files?

3)JNA是否可以在所有java/native互操作涉及从Java调用本机库的情况下正常工作(我假设这是JNA的经典用例)?还是有时需要JNI?

3) Is JNA gauranteed to work in all cases where the only java/native interop involves calling native libraries from Java (I assume this is the classic use case for JNA) -- or is JNI sometimes required instead?

推荐答案

1) depends.exe 在Windows上,nm等.在* nix变体上.

1) depends.exe on windows, objdump, nm, et al. on *nix variants.

2)大多数共享库都是为C样式链接设计的.通常,这意味着您可以在库中查找与符号相对应的地址,但是类型(变量,常量或函数)和签名信息(用于函数)通常不嵌入库中.

2) Most shared libraries are designed for C-style linkage. This generally means that you can look up addresses corresponding to symbols in the library, but the type (variable, constant, or function) and signature information (for functions) is not usually embedded in the library.

3)JNA使用很少的广义JNI操作来执行其所有功能:打开共享库,查找符号,读/写内存,调用函数.在极少数情况下,至少在处理具有C链接的库时,您会拥有在JNA上使用JNI.

3) JNA uses a very few generalized JNI operations to perform all its magic: open shared libraries, look up symbols, read/write memory, call functions. There are very few situations where you would have to use JNI over JNA, at least when dealing with libraries with C linkage.

这篇关于在本机库中找到公开的方法以通过JNA/JNI进行访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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