2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android Studio でビルドされたクラスのメソッドのシグネチャを確認する

Last updated at Posted at 2016-11-11

概要

javap -s を使う

クラスファイルは app/build/intermediates/classes/debug/パッケージ/クラス名.class に入っている

javap -s /path/to/HogefugaApp/app/build/intermediates/classes/debug/com/covelline/hogefugaapp/FooManager.class

背景

JNI で C++ から Java のメソッドを叩く時に、メソッドシグネチャが欲しい

Java のクラスがこういうふうになっている場合について

package com.covelline.hogefugaapp;

import android.content.Context;

public class FooManager {
    private Context context;

    FooManager(Context context) {
        this.context = context;
    }

    public void removeAll() {
        // ...
    }

    public void load(int index, String name) {
        // ...
    }

    public void restart(int index) {
        // ...
    }

    public boolean isAvailable(int index) {
        // ...
    }

    public byte[] getImage(int id) {
        // ...
    }
}

結果

javap -s の出力はこうなる

欲しかった byte[] getFrame(int id) のシグネチャは (I)[B だとわかった

Compiled from "FooManager.java"
public class com.covelline.hogefugaapp.FooManager {
  com.covelline.hogefugaapp.FooManager(android.content.Context);
    descriptor: (Landroid/content/Context;)V

  public void removeAll();
    descriptor: ()V

  public void load(int, java.lang.String);
    descriptor: (ILjava/lang/String;)V

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

  public boolean isAvailable(int);
    descriptor: (I)Z

  public byte[] getFrame(int);
    descriptor: (I)[B
}
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?