javap -s 查看java方法签名

工程先用eclipse生成class目录,转到class目录下执行: javap -s com.example.hellojni.MainActivity

Compiled from "MainActivity.java"
public class com.example.hellojni.MainActivity extends android.app.Activity {
static {};
Signature: ()V public com.example.hellojni.MainActivity();
Signature: ()V protected void onCreate(android.os.Bundle);
Signature: (Landroid/os/Bundle;)V public boolean onCreateOptionsMenu(android.view.Menu);
Signature: (Landroid/view/Menu;)Z public native java.lang.String stringFromJNI(); //native 方法
Signature: ()Ljava/lang/String; //签名 public native int max(int, int); //native 方法
Signature: (II)I //签名
}

最后附上com/example/hellojni/MainActivity.java代码:

 package com.example.hellojni;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView; public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = new TextView(this);
tv.setText( stringFromJNI() );
setContentView(tv);
Log.d("JNI", "max = " + max(, ));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
} public native String stringFromJNI();
public native int max(int a,int b);
static {
System.loadLibrary("hellojni");
}
}
上一篇:Problem A


下一篇:第65节:Java后端的学习之Spring基础