您现在的位置:首页 > 博客 > Android开发 > 正文
Android NDK调用时Java 的类型与虚拟机中的表示对照表
http://www.drovik.com/      2013-3-18 14:32:53      来源:www.drovik.com      点击:
字节码助记符的前缀:

类型        代码        示例            描述 
byte       b             baload     从数组装载 byte 类型 
short     s             sastore         将 short 类型存入数组中 
int           i             iload_1         从局部变量 1 中装载 int 类型 
long       l             lcmp             比较 long 类型值 
char          c         i2c             把int 类型数据转换为 char 类型 
float         f         fload         从局部变量中装载 float 类型 
double     d     dconst_1     将 double 类型常量 1.0 压入栈 
reference a     aaload     从数组装载引用类型 


Java 虚拟机中的保存类型和计算类型:

保存类型     堆或者方法区中的最小比特数     计算类型 Java 栈帧中的字长 
byte                                 8                                     int 1 
short                                 16                                 int 1 
int                                     32                                 int 1 
long                                 64                                 long 2 
char                                 16                                 int 1 
float                                 32                                 float 1 
double                             64                                 double 2 
reference                         32                                 reference 1 


基本类型终结符:

终结符     类型 
B             byte 
C             char 
D             double 
F              float 
I                 int 
J                 long 
S             short 
Z             boolean 

boolean 的终结符不为 B 是让 byte 占用了,long 的终结符不是 L 也是因为让对象终结符占用了。返回值为 void 类型的终结符是 V,对象类型终结符为 L 和 ;,数组类型终结符 [

字段描述符示例

描述符     字段声明 
I                 int i 
[[J             long[][] windingRoad 
[Ljava/lang/Object;     Object[] stuff 
Ljava/util.Hashtable;         java.util.Hashtable ht 
[[[Z                                     boolean[][][] isReady 

方法描述符示例

描述符 方法声明 
()I             int getSize() 
()Ljava/lang/String;         String toString() 
([Ljava/lang/String;)V     void main(String[] args) 
()V                                     void wait() 
(JI)V                                 void wait(long timeout, int nanos) 
(Z[Ljava/lang/String;II)Z             boolean regionMatches(boolean ignoreCase, int toOffset, String other, in oooffset, int len 
([BII)I                             int read(byte[] b, int off, int len) 

执行一下 javap -s java.util.Date 来看看 java.util.Date 的所有方法签名,下面列出一个片断:

C:\Documents and Settings\Administrator>javap -s java.util.Date
Compiled from "Date.java"
public class java.util.Date extends java.lang.Object implements java............
public java.util.Date();
  Signature: ()V
public java.util.Date(long);
  Signature: (J)V
public java.util.Date(int, int, int);
  Signature: (III)V
public java.util.Date(int, int, int, int, int);
  Signature: (IIIII)V
public java.util.Date(int, int, int, int, int, int);
  Signature: (IIIIII)V
public java.util.Date(java.lang.String);
  Signature: (Ljava/lang/String;)V
public java.lang.Object clone();
  Signature: ()Ljava/lang/Object;
public static long UTC(int, int, int, int, int, int);
  Signature: (IIIIII)J
public static long parse(java.lang.String);
  Signature: (Ljava/lang/String;)J
public int getYear();

分享到:
发表评论(0)
姓名 *
评论内容 *
验证码 *图片看不清?点击重新得到验证码