JNIデータ型とタイプ署名

3627 ワード

1.JNIデータ型
1.1基本データ型(java型:JNI型)
int:jint byte:jbyte long:jlong double:jdouble fload:jfload short:jshort boolean:jboolean char:jchar
1.2オブジェクトタイプ
class:jclass throwable:jthrowable string:jstringはjclass,jthrowable,jstringを除いてjobjectで表されます.
1.3配列タイプ
char[]:jcharArray byte[]:jbyteArray int[]:jintArray float[]:jfloatArray long[]:jlongArray double[]:jdoubleArray boolean[]:jbooleanArray object[]:jobjectArray
2.JNIタイプ署名説明
1.1基本タイプ署名
byte B beal: Z long: J int:I float: F double:D short:S
1.2オブジェクトタイプ署名
参照先:L/;String: Ljava/lang/String; Object:Ljava/lang/Object; MediaPlayer:Landroid/media/MediaPlayer;
1.3配列タイプ署名
byte[] :[B int[]: [I short[]:[S float[]:[F double[]:[D boolean[]:[Z long[]:[J String[]:[Ljava/lang/String;
3.タイプ署名の例
3.1ドメイン
JAva変数:String s;JNIドメイン:Ljava/lang/String;
JAva変数:String s[];JNIドメイン:[Ljava/lang/String;
3.2関数
nativeメソッド:public void native fromJni(String msg,int i);JNI関数:(Ljava/lang/String;I)V
nativeメソッド:public int[]native fromJni(String[]msg,int[]i);JNI関数:([Ljava/lang/String;[I)]
3.3配列
Java int[]i対応JNI[I Java String]ss対応JNI[Ljava/lang/String;Java boolean[]対応JNI[Z Java float[]]fs対応JNI[[F.......javap-s対応buildファイル対応nativeのclass例えばjavap-s MainActivity.class
 nativeapp javap 
  : javap  
  ,        :
  -help  --help  -?               
  -version                     
  -v  -verbose                   
  -l                                 
  -public                           
  -protected                     /      
  -package                      /    /   
                               (  )
  -p  -private                     
  -c                               
  -s                               
  -sysinfo                          
                                (  ,   ,   , MD5   )
  -constants                     
  -classpath                     
  -cp                            
  -bootclasspath               
nativeapp javap -s MainActivity.class
Compiled from "MainActivity.java"
public class jni.chowen.com.nativeapp.MainActivity extends android.support.v7.app.AppCompatActivity {
  public jni.chowen.com.nativeapp.MainActivity();
    descriptor: ()V

  protected void onCreate(android.os.Bundle);
    descriptor: (Landroid/os/Bundle;)V

  protected void onResume();
    descriptor: ()V

  public native void passBitmap(java.lang.Object);
    descriptor: (Ljava/lang/Object;)V

  public native int add(int, int);
    descriptor: (II)I

  public native java.lang.String stringFromJNI();
    descriptor: ()Ljava/lang/String;

  public native java.lang.String stringFromJNI2();
    descriptor: ()Ljava/lang/String;

  public native java.lang.String fromJaveToNative(java.lang.String);
    descriptor: (Ljava/lang/String;)Ljava/lang/String;

  public native java.lang.String signture(java.lang.String);
    descriptor: (Ljava/lang/String;)Ljava/lang/String;

  public native void throwException(java.lang.String);
    descriptor: (Ljava/lang/String;)V

  public java.lang.String getPackageN();
    descriptor: ()Ljava/lang/String;

  public void fromNativeJNI();
    descriptor: ()V

  public void fromNativeJNI2(java.lang.String);
    descriptor: (Ljava/lang/String;)V

  public static void fromNativeJNI3(java.lang.String);
    descriptor: (Ljava/lang/String;)V

  public static void fromNativeJNI4();
    descriptor: ()V

  public int getValue();
    descriptor: ()I

  public void modifyValue(int);
    descriptor: (I)V

  static {};
    descriptor: ()V
}