javap -s 查看java方法签名

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:42   798   0

工程先用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代码:

 1 package com.example.hellojni;
 2 import android.os.Bundle;
 3 import android.app.Activity;
 4 import android.util.Log;
 5 import android.view.Menu;
 6 import android.widget.TextView;
 7 
 8 public class MainActivity extends Activity {
 9     @Override
10     protected void onCreate(Bundle savedInstanceState) {
11         super.onCreate(savedInstanceState);
12         setContentView(R.layout.activity_main);
13         TextView  tv = new TextView(this);
14         tv.setText( stringFromJNI() );
15         setContentView(tv);        
16         Log.d("JNI", "max = " + max(10, 100));
17     }
18     @Override
19     public boolean onCreateOptionsMenu(Menu menu) {
20         getMenuInflater().inflate(R.menu.main, menu);
21         return true;
22     }
23     
24     public native String  stringFromJNI();
25     public native int max(int a,int b); 
26     static {
27         System.loadLibrary("hellojni");
28     }
29 }

转载于:https://www.cnblogs.com/chuanwei-zhang/p/3941868.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP