• 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代码:

     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 }
  • 相关阅读:
    案例分析:从一则笑话分析需求的陷阱
    2019寒假培训第二天
    2019寒假培训第一天
    牛客网国庆集训派对Day6 题目 2018年
    unique STL讲解和模板
    SPFA 模板
    ACM Shenyang Onsite 2016 题目
    牛客网国庆集训派对Day5 题目 2018年
    The North American Invitational Programming Contest 2017 题目
    牛客网国庆集训派对Day4题目 2018年
  • 原文地址:https://www.cnblogs.com/chuanwei-zhang/p/3941868.html
Copyright © 2020-2023  润新知