On Jun 25, 11:37 am, Abdul Mateen <[email protected]> wrote:
> I want to see the labels,
% dx --dump --bytes <classfile>
For example (apologies for poor formatting -- really wants a monospace
font):
-----
reading Bar.class...
|begin classfile
0000: cafe babe |magic: cafebabe
0004: 0000 |minor_version: 0000
0006: 0031 |major_version: 0031
0008: 0045 |constant_pool_count: 0045
|
|constant_pool:
000a: 0a00 1300 23 | 0001: method{java.lang.Object.<init>:()V}
000f: 0a00 2400 25 | 0002: method{java.lang.Math.random:()D}
0014: 0640 4900 0000| 0003: double{0x4049000000000000 / 50.0}
001a: 0000 00 |
001d: 0900 1200 26 | 0005: field{Bar.mShiftedByte:B}
0022: 0900 1200 27 | 0006: field{Bar.mUshiftedByte:B}
0027: 0900 1200 28 | 0007: field{Bar.mShiftedShort:S}
002c: 0900 1200 29 | 0008: field{Bar.mUshiftedChar:C}
0031: 0900 2a00 2b | 0009: field{java.lang.System.out:Ljava/io/
PrintStream;}
0036: 0700 2c | 000a: type{java.lang.StringBuilder}
0039: 0a00 0a00 23 | 000b: method{java.lang.StringBuilder.<init>:()
V}
003e: 0800 2d | 000c: string{"values: "}
0041: 0a00 0a00 2e | 000d: method{java.lang.StringBuilder.append:
(Ljava/lang/
| String;)Ljava/lang/StringBuilder;}
0046: 0a00 0a00 2f | 000e: method{java.lang.StringBuilder.append:(I)
Ljava/lan
| g/StringBuilder;}
004b: 0a00 0a00 30 | 000f: method{java.lang.StringBuilder.append:(C)
Ljava/lan
| g/StringBuilder;}
0050: 0a00 0a00 31 | 0010: method{java.lang.StringBuilder.toString:()
Ljava/la
| ng/String;}
0055: 0a00 3200 33 | 0011: method{java.io.PrintStream.println:(Ljava/
lang/Str
| ing;)V}
005a: 0700 34 | 0012: type{Bar}
005d: 0700 35 | 0013: type{java.lang.Object}
0060: 0100 0c6d 5368| 0014: utf8{"mShiftedByte"}
-----
This shows you the byte-by-byte decomposition of the class file.
Looking at the constant pool, the first byte is the tag type (or
"label"). For example, the first entry has a tag type of 0x0a,
CONSTANT_Methodref, which has 16-bit indices to the declaring class
and the method's name and type. "dx" does the lookup for you and
shows the string result on the right.
The .class file format is described in chapter 4 of The Java Virtual
Machine Specification. You can buy the 2nd edition in book form, or
see the amended 3rd edition here:
http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf
At any rate, you can see that the constant pool area is a free-flowing
collection of method references, field references, strings, type info,
and so on; each entry must be tagged by type. The DEX format
eliminates the tag bytes. You will find similar things in the code,
e.g. each concrete method has an attribute of type "Code", and
possibly "LineNumberTable".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Android Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---