More info, plz take the reference from jni.h in SUN java / android NDK.
Primitive Types:
Java Language Type
Native Type
Description
boolean
|
jboolean
|
unsigned 8 bits
|
byte
|
jbyte
|
signed 8 bits
|
char
|
jchar
|
unsigned 16 bits
|
short
|
jshort
|
signed 16 bits
|
int
|
jint
|
signed 32 bits
|
long
|
jlong
|
signed 64 bits
|
float
|
jfloat
|
32 bits
|
double
|
jdouble
|
64 bits
|
Jni.h code snippet:
#ifdef HAVE_INTTYPES_H
# include <inttypes.h> /* C99 */
typedef uint8_t jboolean; /* unsigned 8 bits */
typedef int8_t jbyte; /* signed 8 bits */
typedef uint16_t jchar; /* unsigned 16 bits */
typedef int16_t jshort; /* signed 16 bits */
typedef int32_t jint; /* signed 32 bits */
typedef int64_t jlong; /* signed 64 bits */
typedef float jfloat; /* 32-bit IEEE 754 */
typedef double jdouble; /* 64-bit IEEE 754 */
#else
typedef unsigned char jboolean; /* unsigned 8 bits */
typedef signed char jbyte; /* signed 8 bits */
typedef unsigned short jchar; /* unsigned 16 bits */
typedef short jshort; /* signed 16 bits */
typedef int jint; /* signed 32 bits */
typedef long long jlong; /* signed 64 bits */
typedef float jfloat; /* 32-bit IEEE 754 */
typedef double jdouble; /* 64-bit IEEE 754 */
#endif
Class Descriptors:
"int[]" -> "[I"
"double[][][]" -> "[[[D"
Field Descriptors:
The field descriptors for eight primitive types are as follows:
Field Descriptor
Java Language Type
Z
|
boolean
|
B
|
byte
|
C
|
char
|
S
|
short
|
I
|
int
|
J
|
long
|
F
|
float
|
D
|
double
|
Field descriptors of reference types begin with
the "L
"
character, followed by the class descriptor, and terminated by
the ";
"
character. Field descriptors of array types are formed following the
same rule as class descriptors of array classes. The following are some
examples of field descriptors for reference types and their Java
programming language counterparts.
Field Descriptor
Java Language Type
"Ljava/lang/String;"
|
String
|
"[I"
|
int[]
|
"[Ljava/lang/Object;"
|
Object[]
|
Method Descriptors:
Method descriptors are formed by placing the field descriptors of all
argument types in a pair of parentheses, and following that by the
field descriptor of the return type. There are no spaces or other
separator characters between the argument types. "V
" is used to denote the void
method return type. Constructors use "V
" as their return type, and use "<init>
" as their name.
Here are some examples of JNI method descriptors and their corresponding method and constructor types.
Method Descriptor
Java Language Type
"()Ljava/lang/String;"
|
String f();
|
"(ILjava/lang/Class;)J"
|
long f(int i, Class c);
|
"([B)V"
|
String(byte[] bytes);
|
分享到:
相关推荐
3. **JNI类型和数据结构**(03-JNI Types and Data Structures.pdf): - **JNIEnv**:是JNI的核心,它是每个线程特有的,提供了一组函数指针,用于调用本地方法、创建对象、抛出异常等。 - **本地方法签名**:...
#include <sys/types.h> #include #include #include JNIEXPORT jstring JNICALL Java_com_example_MyApp_getWifiMacAddress(JNIEnv *env, jobject /* this */) { DIR *dir = opendir("/sys/class/wifi"); if ...
simple Java - no need to mess with C/C++ programming with error-prone and hard to use JNI, deploying intermediate DLLs, and dealing with parameter conversions between Java and native types.
在 Java Native Interface (JNI) 和 Google Web Toolkit (GWT) 中,Type Signatures 是一种特殊的表示法,用于描述 Java 类型。这种表示法在 JSNI(Java Script Native Interface)中尤为重要,因为它可以帮助开发者...
add_func.argtypes = [c_int, c_int] add_func.restype = c_int result = add_func(3, 4) print(result) # 输出:7 ``` **Java调用C++动态库** 则需要使用Java Native Interface(JNI)。JNI是Java平台标准的一...
1. `[Content_Types].xml`:这是Microsoft Office Open XML文档的一部分,用于定义文档中不同类型的文件和其对应的MIME类型。在Word文档中,它通常用于指示文档中的图片、图表等元素的类型。 2. `word`:这是一个...
Androidapi.JNI.JavaTypes, FMX.platform, FMX.Platform.Android; type TFrmMain = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; Button3: TButton; PanelOpt: TPanel; Panel2: ...
4. **Java编程**:Java没有内置的枚举系统文件类型的方法,但可以通过JNI(Java Native Interface)调用操作系统API,或者使用第三方库如Apache Commons IO的`FileUtils.getFileExtensions()`方法。 5. **...
myJavaObject.callMethod(name: "myMethod", types: ["()V"], arguments: []) ``` 对于返回值为非void的方法,`callMethod`会返回一个`Any?`类型的值,你可以根据实际情况进行类型转换。 另一方面,如果你想在Java...
FMX.Types; // 用于获取屏幕尺寸 ``` 现在,为按钮的`OnClick`事件编写代码,调用Android的相机服务: ```pascal procedure TForm1.Button1Click(Sender: TObject); var Intent: JIntent; begin Intent := ...
在Android Studio中,开发者需要将库文件放入项目的jniLibs目录下对应的架构目录(如armeabi-v7a_64或x86_64),然后通过Java或Kotlin代码调用JNI接口进行支付操作。 集成银联支付SDK时,还需要注意以下几点: - *...
Androidapi.JNI.JavaTypes, FMX.Helpers.Android; type JConnectivityManager = interface; JNetworkInfo = interface; JNetworkInfoClass = interface (JObjectClass) ['{E92E86E8-0BDE-4D5F-B44E-3148BD...
1. 确保你的Java环境支持JNI,因为TensorFlow Java库是基于JNI实现的。 2. 考虑性能,Java操作TensorFlow可能不如Python原生API快,尤其是在大型模型上。 3. 模型的输入和输出节点名需要与模型定义时一致,可以通过`...
26 JNI (example provided by Leslie Sears) 27 The StringTokenizer Class Part IV -- Database Supplements 1 SQL statements for creating and initializing tables used in the book: SQL Statements in ...
// customization and mapping of Java to native types. public interface CLibrary extends Library { CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), C...
Types of Wake Locks 88 Exploring a Wake Lock Example 88 PowerManager class 89 Registering Drivers with the PM Driver 89 Early Suspend 90 Sensors 90 In this document 90 Building a Sensor Library 91 ...
为了使两者能够互相调用,我们需要一个中间层,这个中间层通常是通过Java Native Interface (JNI) 实现的。然而,对于更简单的场景,如调用Java的预编译类库(jar文件),我们可以利用IKVM.NET这样的开源项目,它...
Androidapi.JNIBase, Androidapi.JNI.JavaTypes, Androidapi.JNI.Content; function GetContactID(const ContactID: Integer): TJavaLocalRef; var Resolver: TJavaLocalRef; begin Resolver := TAndroidHelper....
标签中的"java opengl static-types Java"进一步确认了我们的讨论焦点,即在Java环境中使用OpenGL,并且关注静态类型的安全性。Java开发者可以利用jcanephora来更安全地使用OpenGL,同时保持Java的开发优势,如跨...