zoukankan      html  css  js  c++  java
  • TypesMethodsAndFields

    https://github.com/JesusFreke/smali/wiki/TypesMethodsAndFields

    Types

    dalvik's bytecode has two major classes of types, primitive types and reference types. Reference types are objects and arrays, everything else is a primitive.

    Primitives are represented by a single letter. I didn't come up with these abbreviations - they are what is actually stored in the dex file, in string form. They are specified in the dex-format.html document (dalvik/docs/dex-format.html in the AOSP repository)

    Vvoid - can only be used for return types
    Z boolean
    B byte
    S short
    C char
    I int
    J long (64 bits)
    F float
    D double (64 bits)

    Objects take the form Lpackage/name/ObjectName; - where the leading L indicates that it is an object type, package/name/ is the package that the object is in, ObjectName is the name of the object, and ; denotes the end of the object name. This would be equivalent to package.name.ObjectName in java. Or for a more concrete example, Ljava/lang/String; is equivalent to java.lang.String

    Arrays take the form [I - this would be an array of ints with a single dimension. i.e. int[] in java. For arrays with multiple dimensions, you simply add more [ characters. [[I = int[][][[[I = int[][][], etc. (Note: The maximum number of dimensions you can have is 255).

    You can also have arrays of objects, [Ljava/lang/String; would be an array of Strings.

    Methods

    Methods are always specified in a very verbose form that includes the type that contains the method, the method name, the types of the parameters and the return type. All this information is required for the virtual machine to be able to find the correct method, and to be able to perform static analysis on the bytecode (for verification/optimization purposes)

    They take the form

    Lpackage/name/ObjectName;->MethodName(III)Z
    

    In this example, you should recognize Lpackage/name/ObjectName; as a type. MethodName is obviously the name of the method. (III)Z is the method's signature. III are the parameters (in this case, 3 ints), and Z is the return type (bool).

    The method parameters are listed one right after another, with no separators between them.

    Here's a more complex example:

    method(I[[IILjava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    

    In java, this would be

    String method(int, int[][], int, String, Object[])
    

    Fields

    Fields are likewise always specified in verbose form that includes the type that contains the field, the name of the field, and the type of the field. Again, this is to allow the virtual machine to be able to find the correct field, as well as to perform static analysis on the bytecode.

    They take the form

    Lpackage/name/ObjectName;->FieldName:Ljava/lang/String;
    

    This should be pretty self-explanatory - it is the package name, the field name and the type of the field respectively.

  • 相关阅读:
    mkconfig文件里的"cat << EOF >> config.h"
    (ARM v7)信号量、互斥体代码追踪
    (ARM v7)自旋锁、读写锁、顺序锁代码追踪
    mac 系统上安装navicat
    git2consul配置管理工具使用教程
    Spring Cloud Feign如何上传文件
    spring-cloud feign的多参数传递方案
    Consul下载安装及运行教程
    比SecureCRT更好用的工具MobaXterm下载安装使用教程
    Linux下RocketMQ下载安装教程
  • 原文地址:https://www.cnblogs.com/eustoma/p/8993048.html
Copyright © 2011-2022 走看看