1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dex; 18 19 public final class SizeOf { SizeOf()20 private SizeOf() {} 21 22 public static final int UBYTE = 1; 23 public static final int USHORT = 2; 24 public static final int UINT = 4; 25 26 public static final int SIGNATURE = UBYTE * 20; 27 28 /** 29 * magic ubyte[8] 30 * checksum uint 31 * signature ubyte[20] 32 * file_size uint 33 * header_size uint 34 * endian_tag uint 35 * link_size uint 36 * link_off uint 37 * map_off uint 38 * string_ids_size uint 39 * string_ids_off uint 40 * type_ids_size uint 41 * type_ids_off uint 42 * proto_ids_size uint 43 * proto_ids_off uint 44 * field_ids_size uint 45 * field_ids_off uint 46 * method_ids_size uint 47 * method_ids_off uint 48 * class_defs_size uint 49 * class_defs_off uint 50 * data_size uint 51 * data_off uint 52 */ 53 public static final int HEADER_ITEM = (8 * UBYTE) + UINT + SIGNATURE + (20 * UINT); // 0x70 54 55 /** 56 * string_data_off uint 57 */ 58 public static final int STRING_ID_ITEM = UINT; 59 60 /** 61 * descriptor_idx uint 62 */ 63 public static final int TYPE_ID_ITEM = UINT; 64 65 /** 66 * type_idx ushort 67 */ 68 public static final int TYPE_ITEM = USHORT; 69 70 /** 71 * shorty_idx uint 72 * return_type_idx uint 73 * return_type_idx uint 74 */ 75 public static final int PROTO_ID_ITEM = UINT + UINT + UINT; 76 77 /** 78 * class_idx ushort 79 * type_idx/proto_idx ushort 80 * name_idx uint 81 */ 82 public static final int MEMBER_ID_ITEM = USHORT + USHORT + UINT; 83 84 /** 85 * class_idx uint 86 * access_flags uint 87 * superclass_idx uint 88 * interfaces_off uint 89 * source_file_idx uint 90 * annotations_off uint 91 * class_data_off uint 92 * static_values_off uint 93 */ 94 public static final int CLASS_DEF_ITEM = 8 * UINT; 95 96 /** 97 * type ushort 98 * unused ushort 99 * size uint 100 * offset uint 101 */ 102 public static final int MAP_ITEM = USHORT + USHORT + UINT + UINT; 103 104 /** 105 * start_addr uint 106 * insn_count ushort 107 * handler_off ushort 108 */ 109 public static final int TRY_ITEM = UINT + USHORT + USHORT; 110 } 111