• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 package com.android.tools.r8.dex;
5 
6 public class Constants {
7 
8   public static final byte[] DEX_FILE_MAGIC_PREFIX = {'d', 'e', 'x', '\n'};
9   public static final byte DEX_FILE_MAGIC_SUFFIX = '\0';
10 
11   public static final int ANDROID_O_API = 26;
12   public static final int ANDROID_N_API = 24;
13   public static final int ANDROID_L_API = 21;
14   public static final int ANDROID_K_API = 19;
15   public static final int DEFAULT_ANDROID_API = 1;
16 
17   /** dex file version number for Android O (API level 26) */
18   public static final int ANDROID_O_DEX_VERSION = 38;
19   public static final byte[] ANDROID_O_DEX_VERSION_BYTES = {'0', '3', '8'};
20   /** dex file version number for Android N (API level 24) */
21   public static final int ANDROID_N_DEX_VERSION = 37;
22   public static final byte[] ANDROID_N_DEX_VERSION_BYTES = {'0', '3', '7'};
23   /** dex file version number for all releases prior to Android N */
24   public static final int ANDROID_PRE_N_DEX_VERSION = 35;
25   public static final byte[] ANDROID_PRE_N_DEX_VERSION_BYTES = {'0', '3', '5'};
26 
27   public static final int DEX_MAGIC_SIZE = 8;
28 
29   public static final int HEADER_SIZE = 0x70;
30   public static final int MAGIC_OFFSET = 0;
31   public static final int CHECKSUM_OFFSET = MAGIC_OFFSET + DEX_MAGIC_SIZE;
32   public static final int SIGNATURE_OFFSET = CHECKSUM_OFFSET + 4;
33   public static final int FILE_SIZE_OFFSET = SIGNATURE_OFFSET + 20;
34   public static final int HEADER_SIZE_OFFSET = FILE_SIZE_OFFSET + 4;
35   public static final int ENDIAN_TAG_OFFSET = HEADER_SIZE_OFFSET + 4;
36   public static final int LINK_SIZE_OFFSET = ENDIAN_TAG_OFFSET + 4;
37   public static final int LINK_OFF_OFFSET = LINK_SIZE_OFFSET + 4;
38   public static final int MAP_OFF_OFFSET = LINK_OFF_OFFSET + 4;
39   public static final int STRING_IDS_SIZE_OFFSET = MAP_OFF_OFFSET + 4;
40   public static final int STRING_IDS_OFF_OFFSET = STRING_IDS_SIZE_OFFSET + 4;
41   public static final int TYPE_IDS_SIZE_OFFSET = STRING_IDS_OFF_OFFSET + 4;
42   public static final int TYPE_IDS_OFF_OFFSET = TYPE_IDS_SIZE_OFFSET + 4;
43   public static final int PROTO_IDS_SIZE_OFFSET = TYPE_IDS_OFF_OFFSET + 4;
44   public static final int PROTO_IDS_OFF_OFFSET = PROTO_IDS_SIZE_OFFSET + 4;
45   public static final int FIELD_IDS_SIZE_OFFSET = PROTO_IDS_OFF_OFFSET + 4;
46   public static final int FIELD_IDS_OFF_OFFSET = FIELD_IDS_SIZE_OFFSET + 4;
47   public static final int METHOD_IDS_SIZE_OFFSET = FIELD_IDS_OFF_OFFSET + 4;
48   public static final int METHOD_IDS_OFF_OFFSET = METHOD_IDS_SIZE_OFFSET + 4;
49   public static final int CLASS_DEFS_SIZE_OFFSET = METHOD_IDS_OFF_OFFSET + 4;
50   public static final int CLASS_DEFS_OFF_OFFSET = CLASS_DEFS_SIZE_OFFSET + 4;
51   public static final int DATA_SIZE_OFFSET = CLASS_DEFS_OFF_OFFSET + 4;
52   public static final int DATA_OFF_OFFSET = DATA_SIZE_OFFSET + 4;
53 
54   public static final int ENDIAN_CONSTANT = 0x12345678;
55   public static final int REVERSE_ENDIAN_CONSTANT = 0x78563412;
56 
57   public static final int TYPE_HEADER_ITEM = 0x0;
58   public static final int TYPE_HEADER_ITEM_SIZE = 0x70;
59   public static final int TYPE_STRING_ID_ITEM = 0x0001;
60   public static final int TYPE_STRING_ID_ITEM_SIZE = 0x04;
61   public static final int TYPE_TYPE_ID_ITEM = 0x0002;
62   public static final int TYPE_TYPE_ID_ITEM_SIZE = 0x04;
63   public static final int TYPE_PROTO_ID_ITEM = 0x0003;
64   public static final int TYPE_PROTO_ID_ITEM_SIZE = 0x0c;
65   public static final int TYPE_FIELD_ID_ITEM = 0x0004;
66   public static final int TYPE_FIELD_ID_ITEM_SIZE = 0x08;
67   public static final int TYPE_METHOD_ID_ITEM = 0x0005;
68   public static final int TYPE_METHOD_ID_ITEM_SIZE = 0x08;
69   public static final int TYPE_CLASS_DEF_ITEM = 0x0006;
70   public static final int TYPE_CLASS_DEF_ITEM_SIZE = 0x20;
71   public static final int TYPE_CALL_SITE_ID_ITEM = 0x0007;
72   public static final int TYPE_CALL_SITE_ID_ITEM_SIZE = 0x04;
73   public static final int TYPE_METHOD_HANDLE_ITEM = 0x0008;
74   public static final int TYPE_METHOD_HANDLE_ITEM_SIZE = 0x0008;
75   public static final int TYPE_MAP_LIST = 0x1000;
76   public static final int TYPE_MAP_LIST_ITEM_SIZE = 0x0c;
77   public static final int TYPE_TYPE_LIST = 0x1001;
78   public static final int TYPE_ANNOTATION_SET_REF_LIST = 0x1002;
79   public static final int TYPE_ANNOTATION_SET_ITEM = 0x1003;
80   public static final int TYPE_CLASS_DATA_ITEM = 0x2000;
81   public static final int TYPE_CODE_ITEM = 0x2001;
82   public static final int TYPE_STRING_DATA_ITEM = 0x2002;
83   public static final int TYPE_DEBUG_INFO_ITEM = 0x2003;
84   public static final int TYPE_ANNOTATION_ITEM = 0x2004;
85   public static final int TYPE_ENCODED_ARRAY_ITEM = 0x2005;
86   public static final int TYPE_ANNOTATIONS_DIRECTORY_ITEM = 0x2006;
87 
88   public static final int DBG_START_LOCAL = 0x03;
89   public static final int DBG_START_LOCAL_EXTENDED = 0x04;
90   public static final int DBG_END_LOCAL = 0x05;
91   public static final int DBG_RESTART_LOCAL = 0x06;
92   public static final int DBG_SET_FILE = 0x09;
93   public static final int DBG_END_SEQUENCE = 0x00;
94   public static final int DBG_ADVANCE_PC = 0x01;
95   public static final int DBG_ADVANCE_LINE = 0x02;
96   public static final int DBG_SET_PROLOGUE_END = 0x07;
97   public static final int DBG_SET_EPILOGUE_BEGIN = 0x08;
98   public static final int DBG_FIRST_SPECIAL = 0x0a;
99   public static final int DBG_LAST_SPECIAL = 0xff;
100   public static final int DBG_LINE_BASE = -4;
101   public static final int DBG_LINE_RANGE = 15;
102   public static final int DBG_ADDRESS_RANGE = 16;
103 
104   public static final int NO_OFFSET = 0;
105   public static final int NO_INDEX = -1;
106 
107   public static final int S4BIT_SIGN_MASK = 1 << 3;
108   public static final int S4BIT_MIN = -(1 << 3);
109   public static final int S4BIT_MAX = (1 << 3) - 1;
110   public static final int S8BIT_MIN = -(1 << 7);
111   public static final int S8BIT_MAX = (1 << 7) - 1;
112 
113   public static final int U4BIT_MAX = (1 << 4) - 1;
114   public static final int U8BIT_MAX = (1 << 8) - 1;
115   public static final int U16BIT_MAX = (1 << 16) - 1;
116   public static final long U32BIT_MAX = (1L << 32) - 1;
117   public static final int ACC_PUBLIC = 0x1;
118   public static final int ACC_PRIVATE = 0x2;
119   public static final int ACC_PROTECTED = 0x4;
120   public static final int ACC_STATIC = 0x8;
121   public static final int ACC_FINAL = 0x10;
122   public static final int ACC_SYNCHRONIZED = 0x20;
123   public static final int ACC_VOLATILE = 0x40;
124   public static final int ACC_BRIDGE = 0x40;
125   public static final int ACC_TRANSIENT = 0x80;
126   public static final int ACC_VARARGS = 0x80;
127   public static final int ACC_NATIVE = 0x100;
128   public static final int ACC_INTERFACE = 0x200;
129   public static final int ACC_ABSTRACT = 0x400;
130   public static final int ACC_STRICT = 0x800;
131   public static final int ACC_SYNTHETIC = 0x1000;
132   public static final int ACC_ANNOTATION = 0x2000;
133   public static final int ACC_ENUM = 0x4000;
134   public static final int ACC_CONSTRUCTOR = 0x10000;
135   public static final int ACC_DECLARED_SYNCHRONIZED = 0x20000;
136 
137   public static final String JAVA_LANG_OBJECT_NAME = "java/lang/Object";
138   public static final String INSTANCE_INITIALIZER_NAME = "<init>";
139   public static final String CLASS_INITIALIZER_NAME = "<clinit>";
140 
141   public static final int MAX_NON_JUMBO_INDEX = U16BIT_MAX;
142   public static final int FIRST_JUMBO_INDEX = MAX_NON_JUMBO_INDEX + 1;
143 
144   public static final int KILOBYTE = 1 << 10;
145 }
146