• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 package proguard.classfile;
22 
23 /**
24  * Constants used in representing a Java class (*.class).
25  *
26  * @author Eric Lafortune
27  */
28 public interface ClassConstants
29 {
30     public static final String CLASS_FILE_EXTENSION = ".class";
31 
32     public static final int MAGIC = 0xCAFEBABE;
33 
34     public static final int INTERNAL_CLASS_VERSION_1_0_MAJOR = 45;
35     public static final int INTERNAL_CLASS_VERSION_1_0_MINOR = 3;
36     public static final int INTERNAL_CLASS_VERSION_1_2_MAJOR = 46;
37     public static final int INTERNAL_CLASS_VERSION_1_2_MINOR = 0;
38     public static final int INTERNAL_CLASS_VERSION_1_3_MAJOR = 47;
39     public static final int INTERNAL_CLASS_VERSION_1_3_MINOR = 0;
40     public static final int INTERNAL_CLASS_VERSION_1_4_MAJOR = 48;
41     public static final int INTERNAL_CLASS_VERSION_1_4_MINOR = 0;
42     public static final int INTERNAL_CLASS_VERSION_1_5_MAJOR = 49;
43     public static final int INTERNAL_CLASS_VERSION_1_5_MINOR = 0;
44     public static final int INTERNAL_CLASS_VERSION_1_6_MAJOR = 50;
45     public static final int INTERNAL_CLASS_VERSION_1_6_MINOR = 0;
46 
47     public static final int INTERNAL_CLASS_VERSION_1_0 = (INTERNAL_CLASS_VERSION_1_0_MAJOR << 16) | INTERNAL_CLASS_VERSION_1_0_MINOR;
48     public static final int INTERNAL_CLASS_VERSION_1_2 = (INTERNAL_CLASS_VERSION_1_2_MAJOR << 16) | INTERNAL_CLASS_VERSION_1_2_MINOR;
49     public static final int INTERNAL_CLASS_VERSION_1_3 = (INTERNAL_CLASS_VERSION_1_3_MAJOR << 16) | INTERNAL_CLASS_VERSION_1_3_MINOR;
50     public static final int INTERNAL_CLASS_VERSION_1_4 = (INTERNAL_CLASS_VERSION_1_4_MAJOR << 16) | INTERNAL_CLASS_VERSION_1_4_MINOR;
51     public static final int INTERNAL_CLASS_VERSION_1_5 = (INTERNAL_CLASS_VERSION_1_5_MAJOR << 16) | INTERNAL_CLASS_VERSION_1_5_MINOR;
52     public static final int INTERNAL_CLASS_VERSION_1_6 = (INTERNAL_CLASS_VERSION_1_6_MAJOR << 16) | INTERNAL_CLASS_VERSION_1_6_MINOR;
53 
54     public static final String EXTERNAL_CLASS_VERSION_1_0       = "1.0";
55     public static final String EXTERNAL_CLASS_VERSION_1_1       = "1.1";
56     public static final String EXTERNAL_CLASS_VERSION_1_2       = "1.2";
57     public static final String EXTERNAL_CLASS_VERSION_1_3       = "1.3";
58     public static final String EXTERNAL_CLASS_VERSION_1_4       = "1.4";
59     public static final String EXTERNAL_CLASS_VERSION_1_5       = "1.5";
60     public static final String EXTERNAL_CLASS_VERSION_1_6       = "1.6";
61     public static final String EXTERNAL_CLASS_VERSION_1_5_ALIAS = "5";
62     public static final String EXTERNAL_CLASS_VERSION_1_6_ALIAS = "6";
63 
64     public static final int INTERNAL_ACC_PUBLIC       = 0x0001;
65     public static final int INTERNAL_ACC_PRIVATE      = 0x0002;
66     public static final int INTERNAL_ACC_PROTECTED    = 0x0004;
67     public static final int INTERNAL_ACC_STATIC       = 0x0008;
68     public static final int INTERNAL_ACC_FINAL        = 0x0010;
69     public static final int INTERNAL_ACC_SUPER        = 0x0020;
70     public static final int INTERNAL_ACC_SYNCHRONIZED = 0x0020;
71     public static final int INTERNAL_ACC_VOLATILE     = 0x0040;
72     public static final int INTERNAL_ACC_TRANSIENT    = 0x0080;
73     public static final int INTERNAL_ACC_BRIDGE       = 0x0040;
74     public static final int INTERNAL_ACC_VARARGS      = 0x0080;
75     public static final int INTERNAL_ACC_NATIVE       = 0x0100;
76     public static final int INTERNAL_ACC_INTERFACE    = 0x0200;
77     public static final int INTERNAL_ACC_ABSTRACT     = 0x0400;
78     public static final int INTERNAL_ACC_STRICT       = 0x0800;
79     public static final int INTERNAL_ACC_SYNTHETIC    = 0x1000;
80     public static final int INTERNAL_ACC_ANNOTATTION  = 0x2000;
81     public static final int INTERNAL_ACC_ENUM         = 0x4000;
82 
83     public static final int VALID_INTERNAL_ACC_CLASS  = INTERNAL_ACC_PUBLIC       |
84                                                         INTERNAL_ACC_FINAL        |
85                                                         INTERNAL_ACC_SUPER        |
86                                                         INTERNAL_ACC_INTERFACE    |
87                                                         INTERNAL_ACC_ABSTRACT     |
88                                                         INTERNAL_ACC_SYNTHETIC    |
89                                                         INTERNAL_ACC_ANNOTATTION  |
90                                                         INTERNAL_ACC_ENUM;
91     public static final int VALID_INTERNAL_ACC_FIELD  = INTERNAL_ACC_PUBLIC       |
92                                                         INTERNAL_ACC_PRIVATE      |
93                                                         INTERNAL_ACC_PROTECTED    |
94                                                         INTERNAL_ACC_STATIC       |
95                                                         INTERNAL_ACC_FINAL        |
96                                                         INTERNAL_ACC_VOLATILE     |
97                                                         INTERNAL_ACC_TRANSIENT    |
98                                                         INTERNAL_ACC_SYNTHETIC    |
99                                                         INTERNAL_ACC_ENUM;
100     public static final int VALID_INTERNAL_ACC_METHOD = INTERNAL_ACC_PUBLIC       |
101                                                         INTERNAL_ACC_PRIVATE      |
102                                                         INTERNAL_ACC_PROTECTED    |
103                                                         INTERNAL_ACC_STATIC       |
104                                                         INTERNAL_ACC_FINAL        |
105                                                         INTERNAL_ACC_SYNCHRONIZED |
106                                                         INTERNAL_ACC_BRIDGE       |
107                                                         INTERNAL_ACC_VARARGS      |
108                                                         INTERNAL_ACC_NATIVE       |
109                                                         INTERNAL_ACC_ABSTRACT     |
110                                                         INTERNAL_ACC_STRICT       |
111                                                         INTERNAL_ACC_SYNTHETIC;
112 
113     public static final String EXTERNAL_ACC_PUBLIC       = "public";
114     public static final String EXTERNAL_ACC_PRIVATE      = "private";
115     public static final String EXTERNAL_ACC_PROTECTED    = "protected";
116     public static final String EXTERNAL_ACC_STATIC       = "static";
117     public static final String EXTERNAL_ACC_FINAL        = "final";
118     public static final String EXTERNAL_ACC_SUPER        = "super";
119     public static final String EXTERNAL_ACC_SYNCHRONIZED = "synchronized";
120     public static final String EXTERNAL_ACC_VOLATILE     = "volatile";
121     public static final String EXTERNAL_ACC_TRANSIENT    = "transient";
122     public static final String EXTERNAL_ACC_NATIVE       = "native";
123     public static final String EXTERNAL_ACC_INTERFACE    = "interface";
124     public static final String EXTERNAL_ACC_ABSTRACT     = "abstract";
125     public static final String EXTERNAL_ACC_STRICT       = "strictfp";
126     public static final String EXTERNAL_ACC_ANNOTATION   = "@";
127     public static final String EXTERNAL_ACC_ENUM         = "enum";
128 
129     public static final int CONSTANT_Utf8               = 1;
130     public static final int CONSTANT_Integer            = 3;
131     public static final int CONSTANT_Float              = 4;
132     public static final int CONSTANT_Long               = 5;
133     public static final int CONSTANT_Double             = 6;
134     public static final int CONSTANT_Class              = 7;
135     public static final int CONSTANT_String             = 8;
136     public static final int CONSTANT_Fieldref           = 9;
137     public static final int CONSTANT_Methodref          = 10;
138     public static final int CONSTANT_InterfaceMethodref = 11;
139     public static final int CONSTANT_NameAndType        = 12;
140 
141     public static final String ATTR_SourceFile                           = "SourceFile";
142     public static final String ATTR_SourceDir                            = "SourceDir";
143     public static final String ATTR_InnerClasses                         = "InnerClasses";
144     public static final String ATTR_EnclosingMethod                      = "EnclosingMethod";
145     public static final String ATTR_Deprecated                           = "Deprecated";
146     public static final String ATTR_Synthetic                            = "Synthetic";
147     public static final String ATTR_Signature                            = "Signature";
148     public static final String ATTR_ConstantValue                        = "ConstantValue";
149     public static final String ATTR_Exceptions                           = "Exceptions";
150     public static final String ATTR_Code                                 = "Code";
151     public static final String ATTR_StackMap                             = "StackMap";
152     public static final String ATTR_StackMapTable                        = "StackMapTable";
153     public static final String ATTR_LineNumberTable                      = "LineNumberTable";
154     public static final String ATTR_LocalVariableTable                   = "LocalVariableTable";
155     public static final String ATTR_LocalVariableTypeTable               = "LocalVariableTypeTable";
156     public static final String ATTR_RuntimeVisibleAnnotations            = "RuntimeVisibleAnnotations";
157     public static final String ATTR_RuntimeInvisibleAnnotations          = "RuntimeInvisibleAnnotations";
158     public static final String ATTR_RuntimeVisibleParameterAnnotations   = "RuntimeVisibleParameterAnnotations";
159     public static final String ATTR_RuntimeInvisibleParameterAnnotations = "RuntimeInvisibleParameterAnnotations";
160     public static final String ATTR_AnnotationDefault                    = "AnnotationDefault";
161 
162     public static final int ELEMENT_VALUE_STRING_CONSTANT = 's';
163     public static final int ELEMENT_VALUE_ENUM_CONSTANT   = 'e';
164     public static final int ELEMENT_VALUE_CLASS           = 'c';
165     public static final int ELEMENT_VALUE_ANNOTATION      = '@';
166     public static final int ELEMENT_VALUE_ARRAY           = '[';
167 
168     public static final char EXTERNAL_PACKAGE_SEPARATOR     = '.';
169     public static final char EXTERNAL_INNER_CLASS_SEPARATOR = '.';
170     public static final char INTERNAL_PACKAGE_SEPARATOR     = '/';
171     public static final char INTERNAL_INNER_CLASS_SEPARATOR = '$';
172     public static final char SPECIAL_CLASS_CHARACTER        = '-';
173     public static final char SPECIAL_MEMBER_SEPARATOR       = '$';
174 
175     public static final char EXTERNAL_METHOD_ARGUMENTS_OPEN      = '(';
176     public static final char EXTERNAL_METHOD_ARGUMENTS_CLOSE     = ')';
177     public static final char EXTERNAL_METHOD_ARGUMENTS_SEPARATOR = ',';
178 
179     public static final char INTERNAL_METHOD_ARGUMENTS_OPEN  = '(';
180     public static final char INTERNAL_METHOD_ARGUMENTS_CLOSE = ')';
181 
182     public static final String INTERNAL_PACKAGE_JAVA_LANG         = "java/lang/";
183     public static final String INTERNAL_NAME_JAVA_LANG_OBJECT     = "java/lang/Object";
184     public static final String INTERNAL_TYPE_JAVA_LANG_OBJECT     = "Ljava/lang/Object;";
185     public static final String INTERNAL_NAME_JAVA_LANG_CLONEABLE  = "java/lang/Cloneable";
186     public static final String INTERNAL_NAME_JAVA_LANG_THROWABLE  = "java/lang/Throwable";
187     public static final String INTERNAL_NAME_JAVA_LANG_CLASS      = "java/lang/Class";
188     public static final String INTERNAL_NAME_JAVA_LANG_STRING     = "java/lang/String";
189     public static final String INTERNAL_NAME_JAVA_IO_SERIALIZABLE = "java/io/Serializable";
190 
191     public static final String INTERNAL_METHOD_NAME_INIT   = "<init>";
192     public static final String INTERNAL_METHOD_TYPE_INIT   = "()V";
193     public static final String INTERNAL_METHOD_NAME_CLINIT = "<clinit>";
194     public static final String INTERNAL_METHOD_TYPE_CLINIT = "()V";
195 
196     public static final String INTERNAL_METHOD_NAME_CLASS_FOR_NAME            = "forName";
197     public static final String INTERNAL_METHOD_TYPE_CLASS_FOR_NAME            = "(Ljava/lang/String;)Ljava/lang/Class;";
198     public static final String INTERNAL_METHOD_NAME_CLASS_GET_COMPONENT_TYPE  = "getComponentType";
199     public static final String INTERNAL_METHOD_TYPE_CLASS_GET_COMPONENT_TYPE  = "()Ljava/lang/Class;";
200     public static final String INTERNAL_METHOD_NAME_CLASS_GET_FIELD           = "getField";
201     public static final String INTERNAL_METHOD_TYPE_CLASS_GET_FIELD           = "(Ljava/lang/String;)Ljava/lang/reflect/Field;";
202     public static final String INTERNAL_METHOD_NAME_CLASS_GET_DECLARED_FIELD  = "getDeclaredField";
203     public static final String INTERNAL_METHOD_TYPE_CLASS_GET_DECLARED_FIELD  = "(Ljava/lang/String;)Ljava/lang/reflect/Field;";
204     public static final String INTERNAL_METHOD_NAME_CLASS_GET_METHOD          = "getMethod";
205     public static final String INTERNAL_METHOD_TYPE_CLASS_GET_METHOD          = "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;";
206     public static final String INTERNAL_METHOD_NAME_CLASS_GET_DECLARED_METHOD = "getDeclaredMethod";
207     public static final String INTERNAL_METHOD_TYPE_CLASS_GET_DECLARED_METHOD = "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;";
208 
209     public static final String INTERNAL_METHOD_NAME_DOT_CLASS_JAVAC = "class$";
210     public static final String INTERNAL_METHOD_TYPE_DOT_CLASS_JAVAC = "(Ljava/lang/String;)Ljava/lang/Class;";
211     public static final String INTERNAL_METHOD_NAME_DOT_CLASS_JIKES = "class";
212     public static final String INTERNAL_METHOD_TYPE_DOT_CLASS_JIKES = "(Ljava/lang/String;Z)Ljava/lang/Class;";
213 
214     public static final String INTERNAL_METHOD_NAME_NEW_INSTANCE = "newInstance";
215     public static final String INTERNAL_METHOD_TYPE_NEW_INSTANCE = "()Ljava/lang/Object;";
216 
217     public static final char INTERNAL_TYPE_VOID                   = 'V';
218     public static final char INTERNAL_TYPE_BOOLEAN                = 'Z';
219     public static final char INTERNAL_TYPE_BYTE                   = 'B';
220     public static final char INTERNAL_TYPE_CHAR                   = 'C';
221     public static final char INTERNAL_TYPE_SHORT                  = 'S';
222     public static final char INTERNAL_TYPE_INT                    = 'I';
223     public static final char INTERNAL_TYPE_LONG                   = 'J';
224     public static final char INTERNAL_TYPE_FLOAT                  = 'F';
225     public static final char INTERNAL_TYPE_DOUBLE                 = 'D';
226     public static final char INTERNAL_TYPE_CLASS_START            = 'L';
227     public static final char INTERNAL_TYPE_CLASS_END              = ';';
228     public static final char INTERNAL_TYPE_ARRAY                  = '[';
229     public static final char INTERNAL_TYPE_GENERIC_VARIABLE_START = 'T';
230     public static final char INTERNAL_TYPE_GENERIC_START          = '<';
231     public static final char INTERNAL_TYPE_GENERIC_BOUND          = ':';
232     public static final char INTERNAL_TYPE_GENERIC_END            = '>';
233 
234     public static final String EXTERNAL_TYPE_JAVA_LANG_OBJECT = "java.lang.Object";
235     public static final String EXTERNAL_PACKAGE_JAVA_LANG     = "java.lang.";
236 
237     public static final String EXTERNAL_TYPE_VOID    = "void";
238     public static final String EXTERNAL_TYPE_BOOLEAN = "boolean";
239     public static final String EXTERNAL_TYPE_BYTE    = "byte";
240     public static final String EXTERNAL_TYPE_CHAR    = "char";
241     public static final String EXTERNAL_TYPE_SHORT   = "short";
242     public static final String EXTERNAL_TYPE_INT     = "int";
243     public static final String EXTERNAL_TYPE_FLOAT   = "float";
244     public static final String EXTERNAL_TYPE_LONG    = "long";
245     public static final String EXTERNAL_TYPE_DOUBLE  = "double";
246     public static final String EXTERNAL_TYPE_ARRAY   = "[]";
247 
248     public static final int TYPICAL_CONSTANT_POOL_SIZE     = 256;
249     public static final int TYPICAL_FIELD_COUNT            = 64;
250     public static final int TYPICAL_METHOD_COUNT           = 64;
251     public static final int TYPICAL_CODE_LENGTH            = 1024;
252     public static final int TYPICAL_EXCEPTION_TABLE_LENGTH = 16;
253     public static final int TYPICAL_VARIABLES_SIZE         = 64;
254     public static final int TYPICAL_STACK_SIZE             = 16;
255 }
256