美文网首页
3. JNI basic

3. JNI basic

作者: Silly_N_Fool | 来源:发表于2017-01-18 11:35 被阅读0次
  1. java 数据类型
    在java源代码中,每个变量都必须声明一种类型(type)。有两种类型:primitive type和reference type。引用类型引用对象(reference to object),而基本类型直接包含值(directly contain value)。因此,Java数据类型(type)可以分为两大类:基本类型(primitive types)和引用类型(reference types)。primitive types 包括boolean类型以及数值类型(numeric types)。numeric types又分为整型(integer types)和浮点型(floating-point type)。整型有5种:byte short int long char(char本质上是一种特殊的int)。浮点类型有float和double。关系整理一下如下图:


    java type
  2. the JNI working mechanism
    The native functions receives argument in the above JNI types, and returns a value in the JNI type (such as jstring, jintArray). However, native functions operate on their own native types (such as C-string, C's int[]). Hence, there is a need to convert (or transform) between JNI types and the native types.


    working mechanism
  3. challenges
    The most confusing and challenging task in JNI programming is the conversion (or transformation) between JNI reference types (such as jstring, jobject, jintArray, jobjectArray) and native types (C-string, int[]). The JNI Environment interface provides many functions to do the conversion.
    JNI is a C interface, which is not object-oriented. It does not really pass the objects.

相关文章

网友评论

      本文标题:3. JNI basic

      本文链接:https://www.haomeiwen.com/subject/jeevbttx.html