avoid "console==null" problems
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / codegen / ConstantPool.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.codegen;
12
13 import net.sourceforge.phpdt.internal.compiler.ClassFile;
14 import net.sourceforge.phpdt.internal.compiler.classfmt.ClassFileConstants;
15 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
16 import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18 import net.sourceforge.phpdt.internal.compiler.lookup.TypeIds;
19 import net.sourceforge.phpdt.internal.compiler.util.CharOperation;
20
21 /**
22  * This type is used to store all the constant pool entries.
23  */
24 public class ConstantPool implements ClassFileConstants, TypeIds {
25         public static final int DOUBLE_INITIAL_SIZE = 5;
26         public static final int FLOAT_INITIAL_SIZE = 3;
27         public static final int INT_INITIAL_SIZE = 248;
28         public static final int LONG_INITIAL_SIZE = 5;
29         public static final int UTF8_INITIAL_SIZE = 778;
30         public static final int STRING_INITIAL_SIZE = 761;
31         public static final int FIELD_INITIAL_SIZE = 156;
32         public static final int METHOD_INITIAL_SIZE = 236;
33         public static final int INTERFACE_INITIAL_SIZE = 50;
34         public static final int CLASS_INITIAL_SIZE = 86;
35         public static final int NAMEANDTYPE_INITIAL_SIZE = 272;
36         public static final int CONSTANTPOOL_INITIAL_SIZE = 2000;
37         public static final int CONSTANTPOOL_GROW_SIZE = 6000;
38         protected DoubleCache doubleCache;
39         protected FloatCache floatCache;
40         protected IntegerCache intCache;
41         protected LongCache longCache;
42         public CharArrayCache UTF8Cache;
43         protected CharArrayCache stringCache;
44         protected ObjectCache fieldCache;
45         protected ObjectCache methodCache;
46         protected ObjectCache interfaceMethodCache;
47         protected ObjectCache classCache;
48         protected FieldNameAndTypeCache nameAndTypeCacheForFields;
49         protected MethodNameAndTypeCache nameAndTypeCacheForMethods;
50         int[] wellKnownTypes = new int[21];
51         int[] wellKnownMethods = new int[36];
52         int[] wellKnownFields = new int[10];
53         int[] wellKnownFieldNameAndTypes = new int[2];
54         int[] wellKnownMethodNameAndTypes = new int[33];
55         public byte[] poolContent;
56         public int currentIndex = 1;
57         public int currentOffset;
58         // predefined constant index for well known types
59         final static int JAVA_LANG_BOOLEAN_TYPE = 0;
60         final static int JAVA_LANG_BYTE_TYPE = 1;
61         final static int JAVA_LANG_CHARACTER_TYPE = 2;
62         final static int JAVA_LANG_DOUBLE_TYPE = 3;
63         final static int JAVA_LANG_FLOAT_TYPE = 4;
64         final static int JAVA_LANG_INTEGER_TYPE = 5;
65         final static int JAVA_LANG_LONG_TYPE = 6;
66         final static int JAVA_LANG_SHORT_TYPE = 7;
67         final static int JAVA_LANG_VOID_TYPE = 8;
68         final static int JAVA_LANG_CLASS_TYPE = 9;
69         final static int JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE = 10;
70         final static int JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE = 11;
71         final static int JAVA_LANG_OBJECT_TYPE = 12;
72         final static int JAVA_LANG_STRING_TYPE = 13;
73         final static int JAVA_LANG_STRINGBUFFER_TYPE = 14;
74         final static int JAVA_LANG_SYSTEM_TYPE = 15;
75         final static int JAVA_LANG_THROWABLE_TYPE = 16;
76         final static int JAVA_LANG_ERROR_TYPE = 17;
77         final static int JAVA_LANG_EXCEPTION_TYPE = 18;
78         final static int JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE = 19;
79         final static int JAVA_LANG_ASSERTIONERROR_TYPE = 20;
80         
81         // predefined constant index for well known fields  
82         final static int TYPE_BYTE_FIELD = 0;
83         final static int TYPE_SHORT_FIELD = 1;
84         final static int TYPE_CHARACTER_FIELD = 2;
85         final static int TYPE_INTEGER_FIELD = 3;
86         final static int TYPE_LONG_FIELD = 4;
87         final static int TYPE_FLOAT_FIELD = 5;
88         final static int TYPE_DOUBLE_FIELD = 6;
89         final static int TYPE_BOOLEAN_FIELD = 7;
90         final static int TYPE_VOID_FIELD = 8;
91         final static int OUT_SYSTEM_FIELD = 9;
92         // predefined constant index for well known methods 
93         final static int FORNAME_CLASS_METHOD = 0;
94         final static int NOCLASSDEFFOUNDERROR_CONSTR_METHOD = 1;
95         final static int APPEND_INT_METHOD = 2;
96         final static int APPEND_FLOAT_METHOD = 3;
97         final static int APPEND_LONG_METHOD = 4;
98         final static int APPEND_OBJECT_METHOD = 5;
99         final static int APPEND_CHAR_METHOD = 6;
100         final static int APPEND_STRING_METHOD = 7;
101         final static int APPEND_BOOLEAN_METHOD = 8;
102         final static int APPEND_DOUBLE_METHOD = 9;
103         final static int STRINGBUFFER_STRING_CONSTR_METHOD = 10;
104         final static int STRINGBUFFER_DEFAULT_CONSTR_METHOD = 11;
105         final static int STRINGBUFFER_TOSTRING_METHOD = 12;
106         final static int SYSTEM_EXIT_METHOD = 13;
107         final static int THROWABLE_GETMESSAGE_METHOD = 14;
108         final static int JAVALANGERROR_CONSTR_METHOD = 15;
109         final static int GETCONSTRUCTOR_CLASS_METHOD = 16;
110         final static int NEWINSTANCE_CONSTRUCTOR_METHOD = 17;
111         final static int STRING_INTERN_METHOD = 18;
112         final static int VALUEOF_INT_METHOD = 19;
113         final static int VALUEOF_FLOAT_METHOD = 20;
114         final static int VALUEOF_LONG_METHOD = 21;
115         final static int VALUEOF_OBJECT_METHOD = 22;
116         final static int VALUEOF_CHAR_METHOD = 23;
117         final static int VALUEOF_BOOLEAN_METHOD = 24;
118         final static int VALUEOF_DOUBLE_METHOD = 25;
119         final static int ASSERTIONERROR_CONSTR_OBJECT_METHOD = 26;
120         final static int ASSERTIONERROR_CONSTR_INT_METHOD = 27;
121         final static int ASSERTIONERROR_CONSTR_LONG_METHOD = 28;
122         final static int ASSERTIONERROR_CONSTR_FLOAT_METHOD = 29;
123         final static int ASSERTIONERROR_CONSTR_DOUBLE_METHOD = 30;
124         final static int ASSERTIONERROR_CONSTR_BOOLEAN_METHOD = 31;
125         final static int ASSERTIONERROR_CONSTR_CHAR_METHOD = 32;
126         final static int ASSERTIONERROR_DEFAULT_CONSTR_METHOD = 33;
127         final static int DESIREDASSERTIONSTATUS_CLASS_METHOD = 34;
128         final static int GETCLASS_OBJECT_METHOD = 35;
129         // predefined constant index for well known name and type for fields
130         final static int TYPE_JAVALANGCLASS_NAME_AND_TYPE = 0;
131         final static int OUT_SYSTEM_NAME_AND_TYPE = 1;
132         // predefined constant index for well known name and type for methods
133         final static int FORNAME_CLASS_METHOD_NAME_AND_TYPE = 0;
134         final static int CONSTR_STRING_METHOD_NAME_AND_TYPE = 1;
135         final static int DEFAULT_CONSTR_METHOD_NAME_AND_TYPE = 2;
136         final static int APPEND_INT_METHOD_NAME_AND_TYPE = 3;
137         final static int APPEND_FLOAT_METHOD_NAME_AND_TYPE = 4;
138         final static int APPEND_LONG_METHOD_NAME_AND_TYPE = 5;
139         final static int APPEND_OBJECT_METHOD_NAME_AND_TYPE = 6;
140         final static int APPEND_CHAR_METHOD_NAME_AND_TYPE = 7;
141         final static int APPEND_STRING_METHOD_NAME_AND_TYPE = 8;
142         final static int APPEND_BOOLEAN_METHOD_NAME_AND_TYPE = 9;
143         final static int APPEND_DOUBLE_METHOD_NAME_AND_TYPE = 10;
144         final static int TOSTRING_METHOD_NAME_AND_TYPE = 11;
145         final static int EXIT_METHOD_NAME_AND_TYPE = 12;
146         final static int GETMESSAGE_METHOD_NAME_AND_TYPE = 13;
147         final static int GETCONSTRUCTOR_METHOD_NAME_AND_TYPE = 14;
148         final static int NEWINSTANCE_METHOD_NAME_AND_TYPE = 15;
149         final static int INTERN_METHOD_NAME_AND_TYPE = 16;
150         final static int VALUEOF_INT_METHOD_NAME_AND_TYPE = 17;
151         final static int VALUEOF_FLOAT_METHOD_NAME_AND_TYPE = 18;
152         final static int VALUEOF_LONG_METHOD_NAME_AND_TYPE = 19;
153         final static int VALUEOF_OBJECT_METHOD_NAME_AND_TYPE = 20;
154         final static int VALUEOF_CHAR_METHOD_NAME_AND_TYPE = 21;
155         final static int VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE = 22;
156         final static int VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE = 23;
157         final static int CONSTR_INT_METHOD_NAME_AND_TYPE = 24;
158         final static int CONSTR_LONG_METHOD_NAME_AND_TYPE = 25;
159         final static int CONSTR_FLOAT_METHOD_NAME_AND_TYPE = 26;
160         final static int CONSTR_DOUBLE_METHOD_NAME_AND_TYPE = 27;
161         final static int CONSTR_OBJECT_METHOD_NAME_AND_TYPE = 28;
162         final static int CONSTR_CHAR_METHOD_NAME_AND_TYPE = 29;
163         final static int CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE = 30;
164         final static int DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE = 31;
165         final static int GETCLASS_OBJECT_METHOD_NAME_AND_TYPE = 32;
166
167         
168         public ClassFile classFile;
169
170 /**
171  * ConstantPool constructor comment.
172  */
173 public ConstantPool(ClassFile classFile) {
174         this.UTF8Cache = new CharArrayCache(UTF8_INITIAL_SIZE);
175         this.stringCache = new CharArrayCache(STRING_INITIAL_SIZE);
176         this.fieldCache = new ObjectCache(FIELD_INITIAL_SIZE);
177         this.methodCache = new ObjectCache(METHOD_INITIAL_SIZE);
178         this.interfaceMethodCache = new ObjectCache(INTERFACE_INITIAL_SIZE);
179         this.classCache = new ObjectCache(CLASS_INITIAL_SIZE);
180         this.nameAndTypeCacheForMethods = new MethodNameAndTypeCache(NAMEANDTYPE_INITIAL_SIZE);
181         this.nameAndTypeCacheForFields = new FieldNameAndTypeCache(NAMEANDTYPE_INITIAL_SIZE);   
182         this.poolContent = classFile.header;
183         this.currentOffset = classFile.headerOffset;
184         // currentOffset is initialized to 0 by default
185         this.currentIndex = 1;
186         this.classFile = classFile;
187 }
188 /**
189  * Return the content of the receiver
190  */
191 public byte[] dumpBytes() {
192         System.arraycopy(poolContent, 0, (poolContent = new byte[currentOffset]), 0, currentOffset);
193         return poolContent;
194 }
195 /**
196  * Return the index of the @fieldBinding.
197  *
198  * Returns -1 if the @fieldBinding is not a predefined fieldBinding, 
199  * the right index otherwise.
200  *
201  * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
202  * @return <CODE>int</CODE>
203  */
204 public int indexOfWellKnownFieldNameAndType(FieldBinding fieldBinding) {
205         if ((fieldBinding.type.id == T_JavaLangClass) && (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE)))
206                 return TYPE_JAVALANGCLASS_NAME_AND_TYPE;
207         if ((fieldBinding.type.id == T_JavaIoPrintStream) && (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.Out)))
208                 return OUT_SYSTEM_NAME_AND_TYPE;
209         return -1;
210 }
211 /**
212  * Return the index of the @fieldBinding.
213  *
214  * Returns -1 if the @fieldBinding is not a predefined fieldBinding, 
215  * the right index otherwise.
216  *
217  * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
218  * @return <CODE>int</CODE>
219  */
220 public int indexOfWellKnownFields(FieldBinding fieldBinding) {
221         switch (fieldBinding.declaringClass.id) {
222                 case T_JavaLangByte :
223                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
224                                 return TYPE_BYTE_FIELD;
225                         break;
226                 case T_JavaLangShort :
227                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
228                                 return TYPE_SHORT_FIELD;
229                         break;
230                 case T_JavaLangCharacter :
231                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
232                                 return TYPE_CHARACTER_FIELD;
233                         break;
234                 case T_JavaLangInteger :
235                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
236                                 return TYPE_INTEGER_FIELD;
237                         break;
238                 case T_JavaLangLong :
239                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
240                                 return TYPE_LONG_FIELD;
241                         break;
242                 case T_JavaLangFloat :
243                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
244                                 return TYPE_FLOAT_FIELD;
245                         break;
246                 case T_JavaLangDouble :
247                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
248                                 return TYPE_DOUBLE_FIELD;
249                         break;
250                 case T_JavaLangBoolean :
251                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
252                                 return TYPE_BOOLEAN_FIELD;
253                         break;
254                 case T_JavaLangVoid :
255                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
256                                 return TYPE_VOID_FIELD;
257                         break;
258                 case T_JavaLangSystem :
259                         if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.Out))
260                                 return OUT_SYSTEM_FIELD;
261         }
262         return -1;
263 }
264 /**
265  * Return the index of the @methodBinding.
266  *
267  * Returns -1 if the @methodBinding is not a predefined methodBinding, 
268  * the right index otherwise.
269  *
270  * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
271  * @return <CODE>int</CODE>
272  */
273 public int indexOfWellKnownMethodNameAndType(MethodBinding methodBinding) {
274         char firstChar = methodBinding.selector[0];
275         switch (firstChar) {
276                 case 'f' :
277                         if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (methodBinding.returnType.id == T_JavaLangClass) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ForName))) {
278                                 // This method binding is forName(java.lang.String)
279                                 return FORNAME_CLASS_METHOD_NAME_AND_TYPE;
280                         }
281                         break;
282                 case '<' :
283                         if (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
284                                 switch(methodBinding.parameters.length) {
285                                         case 1:
286                                                 switch(methodBinding.parameters[0].id) {
287                                                         case T_String :
288                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.StringConstructorSignature)) {
289                                                                         return CONSTR_STRING_METHOD_NAME_AND_TYPE;      
290                                                                 } else {
291                                                                         return -1;
292                                                                 }
293                                                         case T_Object :
294                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorObjectConstrSignature)) {
295                                                                         return CONSTR_OBJECT_METHOD_NAME_AND_TYPE;
296                                                                 } else {
297                                                                         return -1;
298                                                                 }
299                                                         case T_int :
300                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorIntConstrSignature)) {
301                                                                         return CONSTR_INT_METHOD_NAME_AND_TYPE;
302                                                                 } else {
303                                                                         return -1;
304                                                                 }
305                                                         case T_char :
306                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorCharConstrSignature)) {
307                                                                         return CONSTR_CHAR_METHOD_NAME_AND_TYPE;
308                                                                 } else {
309                                                                         return -1;
310                                                                 }
311                                                         case T_boolean :
312                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorBooleanConstrSignature)) {
313                                                                         return CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE;
314                                                                 } else {
315                                                                         return -1;
316                                                                 }
317                                                         case T_float :
318                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorFloatConstrSignature)) {
319                                                                         return CONSTR_FLOAT_METHOD_NAME_AND_TYPE;
320                                                                 } else {
321                                                                         return -1;
322                                                                 }
323                                                         case T_double :
324                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorDoubleConstrSignature)) {
325                                                                         return CONSTR_DOUBLE_METHOD_NAME_AND_TYPE;
326                                                                 } else {
327                                                                         return -1;
328                                                                 }
329                                                         case T_long :
330                                                                 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorLongConstrSignature)) {
331                                                                         return CONSTR_LONG_METHOD_NAME_AND_TYPE;
332                                                                 } else {
333                                                                         return -1;
334                                                                 }
335                                                 }
336                                         case 0:
337                                                 if (methodBinding.signature().length == 3) {
338                                                         return DEFAULT_CONSTR_METHOD_NAME_AND_TYPE;
339                                                 }
340                                 }
341                         }
342                         break;
343                 case 'a' :
344                         if ((methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
345                                 switch (methodBinding.parameters[0].id) {
346                                         case T_int :
347                                         case T_byte :
348                                         case T_short :
349                                                 // This method binding is append(int)
350                                                 return APPEND_INT_METHOD_NAME_AND_TYPE;
351                                         case T_float :
352                                                 // This method binding is append(float)
353                                                 return APPEND_FLOAT_METHOD_NAME_AND_TYPE;
354                                         case T_long :
355                                                 // This method binding is append(long)
356                                                 return APPEND_LONG_METHOD_NAME_AND_TYPE;
357                                         case T_JavaLangObject :
358                                                 // This method binding is append(java.lang.Object)
359                                                 return APPEND_OBJECT_METHOD_NAME_AND_TYPE;
360                                         case T_char :
361                                                 // This method binding is append(char)
362                                                 return APPEND_CHAR_METHOD_NAME_AND_TYPE;
363                                         case T_JavaLangString :
364                                                 // This method binding is append(java.lang.String)
365                                                 return APPEND_STRING_METHOD_NAME_AND_TYPE;
366                                         case T_boolean :
367                                                 // This method binding is append(boolean)
368                                                 return APPEND_BOOLEAN_METHOD_NAME_AND_TYPE;
369                                         case T_double :
370                                                 // This method binding is append(double)
371                                                 return APPEND_DOUBLE_METHOD_NAME_AND_TYPE;
372                                 }
373                         }
374                         break;
375                 case 't' :
376                         if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
377                                 // This method binding is toString()
378                                 return TOSTRING_METHOD_NAME_AND_TYPE;
379                         }
380                         break;
381                 case 'v' :
382                         if ((methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
383                                 switch(methodBinding.parameters[0].id) {
384                                         case T_Object:
385                                                 return VALUEOF_OBJECT_METHOD_NAME_AND_TYPE;
386                                         case T_int:
387                                         case T_short:
388                                         case T_byte:
389                                                 return VALUEOF_INT_METHOD_NAME_AND_TYPE;
390                                         case T_long:
391                                                 return VALUEOF_LONG_METHOD_NAME_AND_TYPE;
392                                         case T_float:
393                                                 return VALUEOF_FLOAT_METHOD_NAME_AND_TYPE;
394                                         case T_double:
395                                                 return VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE;
396                                         case T_boolean:
397                                                 return VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE;
398                                         case T_char:
399                                                 return VALUEOF_CHAR_METHOD_NAME_AND_TYPE;
400                                 }
401                         }
402                         break;
403                 case 'e' :
404                         if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
405                                 // This method binding is exit(int)
406                                 return EXIT_METHOD_NAME_AND_TYPE;
407                         }
408                         break;
409                 case 'g' :
410                         if ((methodBinding.selector.length == 10)
411                             && (methodBinding.parameters.length == 0)
412                             && (methodBinding.returnType.id == T_JavaLangString)
413                             && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
414                                 // This method binding is getMessage()
415                                 return GETMESSAGE_METHOD_NAME_AND_TYPE;
416                         }
417                         if (methodBinding.parameters.length == 0
418                                 && methodBinding.returnType.id == T_JavaLangClass
419                                 && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
420                                         return GETCLASS_OBJECT_METHOD_NAME_AND_TYPE;
421                         }                               
422                         break;
423                 case 'i' :
424                         if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
425                                 // This method binding is toString()
426                                 return INTERN_METHOD_NAME_AND_TYPE;
427                         }       
428         }
429         return -1;
430 }
431 /**
432  * Return the index of the @methodBinding.
433  *
434  * Returns -1 if the @methodBinding is not a predefined methodBinding, 
435  * the right index otherwise.
436  *
437  * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
438  * @return <CODE>int</CODE>
439  */
440 public int indexOfWellKnownMethods(MethodBinding methodBinding) {
441         char firstChar = methodBinding.selector[0];
442         switch (methodBinding.declaringClass.id) {
443                 case T_JavaLangClass :
444                         if ((firstChar == 'f') && (methodBinding.isStatic()) && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (methodBinding.returnType.id == T_JavaLangClass) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ForName))) {
445                                 // This method binding is forName(java.lang.String)
446                                 return FORNAME_CLASS_METHOD;
447                         } else if ((firstChar == 'g') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangReflectConstructor) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetConstructor) && CharOperation.equals(methodBinding.parameters[0].constantPoolName(), QualifiedNamesConstants.ArrayJavaLangClassConstantPoolName)) {
448                                         return GETCONSTRUCTOR_CLASS_METHOD;
449                         } else if ((firstChar == 'd') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_boolean) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.DesiredAssertionStatus)) {
450                                         return DESIREDASSERTIONSTATUS_CLASS_METHOD;
451                         }
452                         break;
453                 case T_JavaLangNoClassDefError :
454                         if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
455                                 // This method binding is NoClassDefFoundError(java.lang.String)
456                                 return NOCLASSDEFFOUNDERROR_CONSTR_METHOD;
457                         }
458                         break;
459                 case T_JavaLangReflectConstructor :
460                         if ((firstChar == 'n') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangObject) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.NewInstance) && CharOperation.equals(methodBinding.parameters[0].constantPoolName(), QualifiedNamesConstants.ArrayJavaLangObjectConstantPoolName)) {
461                                 return NEWINSTANCE_CONSTRUCTOR_METHOD;
462                         }
463                         break;
464                 case T_JavaLangStringBuffer :
465                         if ((firstChar == 'a') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
466                                 switch (methodBinding.parameters[0].id) {
467                                         case T_int :
468                                         case T_byte :
469                                         case T_short :
470                                                 // This method binding is append(int)
471                                                 return APPEND_INT_METHOD;
472                                         case T_float :
473                                                 // This method binding is append(float)
474                                                 return APPEND_FLOAT_METHOD;
475                                         case T_long :
476                                                 // This method binding is append(long)
477                                                 return APPEND_LONG_METHOD;
478                                         case T_JavaLangObject :
479                                                 // This method binding is append(java.lang.Object)
480                                                 return APPEND_OBJECT_METHOD;
481                                         case T_char :
482                                                 // This method binding is append(char)
483                                                 return APPEND_CHAR_METHOD;
484                                         case T_JavaLangString :
485                                                 // This method binding is append(java.lang.String)
486                                                 return APPEND_STRING_METHOD;
487                                         case T_boolean :
488                                                 // This method binding is append(boolean)
489                                                 return APPEND_BOOLEAN_METHOD;
490                                         case T_double :
491                                                 // This method binding is append(double)
492                                                 return APPEND_DOUBLE_METHOD;
493                                 }
494                         } else
495                                 if ((firstChar == 't') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
496                                         // This method binding is toString()
497                                         return STRINGBUFFER_TOSTRING_METHOD;
498                                 } else
499                                         if ((firstChar == '<') && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
500                                                 if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString)) {
501                                                         // This method binding is <init>(String)                    
502                                                         return STRINGBUFFER_STRING_CONSTR_METHOD;
503                                                 } else {
504                                                         if (methodBinding.parameters.length == 0) {
505                                                                 // This method binding is <init>()
506                                                                 return STRINGBUFFER_DEFAULT_CONSTR_METHOD;
507                                                         }
508                                                 }
509                                         }
510                         break;
511                 case T_JavaLangString :
512                         if ((firstChar == 'v') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
513                                 // This method binding is valueOf(java.lang.Object)
514                                 switch (methodBinding.parameters[0].id) {
515                                         case T_Object :
516                                                 return VALUEOF_OBJECT_METHOD;
517                                         case T_int :
518                                         case T_short :
519                                         case T_byte :
520                                                 return VALUEOF_INT_METHOD;
521                                         case T_long :
522                                                 return VALUEOF_LONG_METHOD;
523                                         case T_float :
524                                                 return VALUEOF_FLOAT_METHOD;
525                                         case T_double :
526                                                 return VALUEOF_DOUBLE_METHOD;
527                                         case T_boolean :
528                                                 return VALUEOF_BOOLEAN_METHOD;
529                                         case T_char :
530                                                 return VALUEOF_CHAR_METHOD;
531                                 }
532                         } else
533                                 if ((firstChar == 'i') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
534                                         // This method binding is valueOf(java.lang.Object)
535                                         return STRING_INTERN_METHOD;
536                                 }
537                         break;
538                 case T_JavaLangSystem :
539                         if ((firstChar == 'e') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
540                                 // This method binding is exit(int)
541                                 return SYSTEM_EXIT_METHOD;
542                         }
543                         break;
544                 case T_JavaLangThrowable :
545                         if ((firstChar == 'g') && (methodBinding.selector.length == 10) && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
546                                 // This method binding is getMessage()
547                                 return THROWABLE_GETMESSAGE_METHOD;
548                         }
549                         break;
550                 case T_JavaLangError :
551                         if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) && (methodBinding.parameters[0].id == T_String)) {
552                                 return JAVALANGERROR_CONSTR_METHOD;
553                         }
554                         break;
555                 case T_JavaLangAssertionError :
556                         if ((firstChar == '<') && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
557                                 switch (methodBinding.parameters.length) {
558                                         case 0:
559                                                 return ASSERTIONERROR_DEFAULT_CONSTR_METHOD;
560                                         case 1:
561                                                 switch(methodBinding.parameters[0].id) {
562                                                         case T_boolean :
563                                                                 return ASSERTIONERROR_CONSTR_BOOLEAN_METHOD;
564                                                         case T_char :
565                                                                 return ASSERTIONERROR_CONSTR_CHAR_METHOD;
566                                                         case T_double :
567                                                                 return ASSERTIONERROR_CONSTR_DOUBLE_METHOD;
568                                                         case T_int :
569                                                         case T_byte :
570                                                         case T_short :
571                                                                 return ASSERTIONERROR_CONSTR_INT_METHOD;
572                                                         case T_float :
573                                                                 return ASSERTIONERROR_CONSTR_FLOAT_METHOD;
574                                                         case T_long :
575                                                                 return ASSERTIONERROR_CONSTR_LONG_METHOD;
576                                                         default:
577                                                                 return ASSERTIONERROR_CONSTR_OBJECT_METHOD;
578                                                 }
579                                 }
580                         }
581                         break;
582                 case T_JavaLangObject :
583                         if (methodBinding.parameters.length == 0
584                                 && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
585                                         return GETCLASS_OBJECT_METHOD;
586                         }                       
587         }
588         return -1;
589 }
590 /**
591  * Return the index of the @typeBinding
592  *
593  * Returns -1 if the @typeBinding is not a predefined binding, the right index 
594  * otherwise.
595  *
596  * @param typeBinding org.eclipse.jdt.internal.compiler.lookup.TypeBinding
597  * @return <CODE>int</CODE>
598  */
599 public int indexOfWellKnownTypes(TypeBinding typeBinding) {
600         switch(typeBinding.id) {
601                 case T_JavaLangBoolean : return JAVA_LANG_BOOLEAN_TYPE;
602                 case T_JavaLangByte : return JAVA_LANG_BYTE_TYPE;
603                 case T_JavaLangCharacter : return JAVA_LANG_CHARACTER_TYPE;
604                 case T_JavaLangDouble : return JAVA_LANG_DOUBLE_TYPE;
605                 case T_JavaLangFloat : return JAVA_LANG_FLOAT_TYPE;
606                 case T_JavaLangInteger : return JAVA_LANG_INTEGER_TYPE;
607                 case T_JavaLangLong : return JAVA_LANG_LONG_TYPE;
608                 case T_JavaLangShort : return JAVA_LANG_SHORT_TYPE;
609                 case T_JavaLangVoid : return JAVA_LANG_VOID_TYPE;
610                 case T_JavaLangClass : return JAVA_LANG_CLASS_TYPE;
611                 case T_JavaLangClassNotFoundException : return JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE;
612                 case T_JavaLangNoClassDefError : return JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE;
613                 case T_JavaLangObject : return JAVA_LANG_OBJECT_TYPE;
614                 case T_JavaLangString : return JAVA_LANG_STRING_TYPE;
615                 case T_JavaLangStringBuffer : return JAVA_LANG_STRINGBUFFER_TYPE;
616                 case T_JavaLangSystem : return JAVA_LANG_SYSTEM_TYPE;
617                 case T_JavaLangThrowable : return JAVA_LANG_THROWABLE_TYPE;
618                 case T_JavaLangError : return JAVA_LANG_ERROR_TYPE;
619                 case T_JavaLangException : return JAVA_LANG_EXCEPTION_TYPE;
620                 case T_JavaLangReflectConstructor : return JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE;
621                 case T_JavaLangAssertionError : return JAVA_LANG_ASSERTIONERROR_TYPE;
622         }
623         return -1;
624 }
625 public int literalIndex(byte[] utf8encoding, char[] stringCharArray) {
626         int index;
627         if ((index = UTF8Cache.get(stringCharArray)) < 0) {
628                 // The entry doesn't exit yet
629                 index = UTF8Cache.put(stringCharArray, currentIndex);
630                 if (index > 0xFFFF){
631                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
632                 }
633                 currentIndex++;
634                 // Write the tag first
635                 writeU1(Utf8Tag);
636                 // Then the size of the stringName array
637                 //writeU2(utf8Constant.length);
638                 int savedCurrentOffset = currentOffset;
639                 if (currentOffset + 2 >= poolContent.length) {
640                         // we need to resize the poolContent array because we won't have
641                         // enough space to write the length
642                         int length = poolContent.length;
643                         System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
644                 }
645                 currentOffset += 2;
646                 // add in once the whole byte array
647                 int length = poolContent.length;
648                 int utf8encodingLength = utf8encoding.length;
649                 if (currentOffset + utf8encodingLength >= length) {
650                         System.arraycopy(poolContent, 0, (poolContent = new byte[length + utf8encodingLength + CONSTANTPOOL_GROW_SIZE]), 0, length);
651                 }
652                 System.arraycopy(utf8encoding, 0, poolContent, currentOffset, utf8encodingLength);
653                 currentOffset += utf8encodingLength;
654                 // Now we know the length that we have to write in the constant pool
655                 // we use savedCurrentOffset to do that
656                 poolContent[savedCurrentOffset] = (byte) (utf8encodingLength >> 8);
657                 poolContent[savedCurrentOffset + 1] = (byte) utf8encodingLength;
658         }
659         return index;
660 }
661 /**
662  * This method returns the index into the constantPool corresponding to the type descriptor.
663  *
664  * @param char[] stringName
665  * @return <CODE>int</CODE>
666  */
667 public int literalIndex(char[] utf8Constant) {
668         int index;
669         if ((index = UTF8Cache.get(utf8Constant)) < 0) {
670                 // The entry doesn't exit yet
671                 // Write the tag first
672                 writeU1(Utf8Tag);
673                 // Then the size of the stringName array
674                 int savedCurrentOffset = currentOffset;
675                 if (currentOffset + 2 >= poolContent.length) {
676                         // we need to resize the poolContent array because we won't have
677                         // enough space to write the length
678                         int length = poolContent.length;
679                         System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
680                 }
681                 currentOffset += 2;
682                 int length = 0;
683                 for (int i = 0; i < utf8Constant.length; i++) {
684                         char current = utf8Constant[i];
685                         if ((current >= 0x0001) && (current <= 0x007F)) {
686                                 // we only need one byte: ASCII table
687                                 writeU1(current);
688                                 length++;
689                         } else
690                                 if (current > 0x07FF) {
691                                         // we need 3 bytes
692                                         length += 3;
693                                         writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
694                                         writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
695                                         writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
696                                 } else {
697                                         // we can be 0 or between 0x0080 and 0x07FF
698                                         // In that case we only need 2 bytes
699                                         length += 2;
700                                         writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
701                                         writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
702                                 }
703                 }
704                 if (length >= 65535) {
705                         currentOffset = savedCurrentOffset - 1;
706                         return -1;
707                 }
708                 index = UTF8Cache.put(utf8Constant, currentIndex);
709                 if (index > 0xFFFF){
710                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
711                 }
712                 currentIndex++;     
713                 // Now we know the length that we have to write in the constant pool
714                 // we use savedCurrentOffset to do that
715                 poolContent[savedCurrentOffset] = (byte) (length >> 8);
716                 poolContent[savedCurrentOffset + 1] = (byte) length;
717         }
718         return index;
719 }
720 public int literalIndex(char[] stringCharArray, byte[] utf8encoding) {
721         int index;
722         int stringIndex;
723         if ((index = stringCache.get(stringCharArray)) < 0) {
724                 // The entry doesn't exit yet
725                 stringIndex = literalIndex(utf8encoding, stringCharArray);
726                 index = stringCache.put(stringCharArray, currentIndex++);
727                 if (index > 0xFFFF){
728                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
729                 }
730                 // Write the tag first
731                 writeU1(StringTag);
732                 // Then the string index
733                 writeU2(stringIndex);
734         }
735         return index;
736 }
737 /**
738  * This method returns the index into the constantPool corresponding to the double
739  * value. If the double is not already present into the pool, it is added. The 
740  * double cache is updated and it returns the right index.
741  *
742  * @param <CODE>double</CODE> key
743  * @return <CODE>int</CODE>
744  */
745 public int literalIndex(double key) {
746         //Retrieve the index from the cache
747         // The double constant takes two indexes into the constant pool, but we only store
748         // the first index into the long table
749         int index;
750         // lazy initialization for base type caches
751         // If it is null, initialize it, otherwise use it
752         if (doubleCache == null) {
753                         doubleCache = new DoubleCache(DOUBLE_INITIAL_SIZE);
754         }
755         if ((index = doubleCache.get(key)) < 0) {
756                 index = doubleCache.put(key, currentIndex++);
757                 if (index > 0xFFFF){
758                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
759                 }
760                 currentIndex++; // a double needs an extra place into the constant pool
761                 // Write the double into the constant pool
762                 // First add the tag
763                 writeU1(DoubleTag);
764                 // Then add the 8 bytes representing the double
765                 long temp = java.lang.Double.doubleToLongBits(key);
766                 for (int i = 0; i < 8; i++) {
767                         try {
768                                 poolContent[currentOffset++] = (byte) (temp >>> (56 - (i << 3)));
769                         } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
770                                 int length = poolContent.length;
771                                 System.arraycopy(poolContent, 0, (poolContent = new byte[(length << 1) + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
772                                 poolContent[currentOffset - 1] = (byte) (temp >>> (56 - (i << 3)));
773                         }
774                 }
775         };
776         return index;
777 }
778 /**
779  * This method returns the index into the constantPool corresponding to the float
780  * value. If the float is not already present into the pool, it is added. The 
781  * int cache is updated and it returns the right index.
782  *
783  * @param <CODE>float</CODE> key
784  * @return <CODE>int</CODE>
785  */
786 public int literalIndex(float key) {
787         //Retrieve the index from the cache
788         int index;
789         // lazy initialization for base type caches
790         // If it is null, initialize it, otherwise use it
791         if (floatCache == null) {
792                 floatCache = new FloatCache(FLOAT_INITIAL_SIZE);
793         }
794         if ((index = floatCache.get(key)) < 0) {
795                 index = floatCache.put(key, currentIndex++);
796                 if (index > 0xFFFF){
797                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
798                 }
799                 // Write the float constant entry into the constant pool
800                 // First add the tag
801                 writeU1(FloatTag);
802                 // Then add the 4 bytes representing the float
803                 int temp = java.lang.Float.floatToIntBits(key);
804                 for (int i = 0; i < 4; i++) {
805                         try {
806                                 poolContent[currentOffset++] = (byte) (temp >>> (24 - i * 8));
807                         } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
808                                 int length = poolContent.length;
809                                 System.arraycopy(poolContent, 0, (poolContent = new byte[length * 2 + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
810                                 poolContent[currentOffset - 1] = (byte) (temp >>> (24 - i * 8));
811                         }
812                 }
813         };
814         return index;
815 }
816 /**
817  * This method returns the index into the constantPool corresponding to the int
818  * value. If the int is not already present into the pool, it is added. The 
819  * int cache is updated and it returns the right index.
820  *
821  * @param <CODE>int</CODE> key
822  * @return <CODE>int</CODE>
823  */
824 public int literalIndex(int key) {
825         //Retrieve the index from the cache
826         int index;
827         // lazy initialization for base type caches
828         // If it is null, initialize it, otherwise use it
829         if (intCache == null) {
830                 intCache = new IntegerCache(INT_INITIAL_SIZE);
831         }
832         if ((index = intCache.get(key)) < 0) {
833                 index = intCache.put(key, currentIndex++);
834                 if (index > 0xFFFF){
835                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
836                 }
837                 // Write the integer constant entry into the constant pool
838                 // First add the tag
839                 writeU1(IntegerTag);
840                 // Then add the 4 bytes representing the int
841                 for (int i = 0; i < 4; i++) {
842                         try {
843                                 poolContent[currentOffset++] = (byte) (key >>> (24 - i * 8));
844                         } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
845                                 int length = poolContent.length;
846                                 System.arraycopy(poolContent, 0, (poolContent = new byte[length * 2 + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
847                                 poolContent[currentOffset - 1] = (byte) (key >>> (24 - i * 8));
848                         }
849                 }
850         };
851         return index;
852 }
853 /**
854  * This method returns the index into the constantPool corresponding to the long
855  * value. If the long is not already present into the pool, it is added. The 
856  * long cache is updated and it returns the right index.
857  *
858  * @param <CODE>long</CODE> key
859  * @return <CODE>int</CODE>
860  */
861 public int literalIndex(long key) {
862         // Retrieve the index from the cache
863         // The long constant takes two indexes into the constant pool, but we only store
864         // the first index into the long table
865         int index;
866         // lazy initialization for base type caches
867         // If it is null, initialize it, otherwise use it
868         if (longCache == null) {
869                 longCache = new LongCache(LONG_INITIAL_SIZE);
870         }
871         if ((index = longCache.get(key)) < 0) {
872                 index = longCache.put(key, currentIndex++);
873                 if (index > 0xFFFF){
874                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
875                 }
876                 currentIndex++; // long value need an extra place into thwe constant pool
877                 // Write the long into the constant pool
878                 // First add the tag
879                 writeU1(LongTag);
880                 // Then add the 8 bytes representing the long
881                 for (int i = 0; i < 8; i++) {
882                         try {
883                                 poolContent[currentOffset++] = (byte) (key >>> (56 - (i << 3)));
884                         } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
885                                 int length = poolContent.length;
886                                 System.arraycopy(poolContent, 0, (poolContent = new byte[(length << 1) + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
887                                 poolContent[currentOffset - 1] = (byte) (key >>> (56 - (i << 3)));
888                         }
889                 }
890         }
891         return index;
892 }
893 /**
894  * This method returns the index into the constantPool corresponding to the type descriptor.
895  *
896  * @param stringConstant java.lang.String
897  * @return <CODE>int</CODE>
898  */
899 public int literalIndex(String stringConstant) {
900         int index;
901         char[] stringCharArray = stringConstant.toCharArray();
902         if ((index = stringCache.get(stringCharArray)) < 0) {
903                 // The entry doesn't exit yet
904                 int stringIndex = literalIndex(stringCharArray);
905                 index = stringCache.put(stringCharArray, currentIndex++);
906                 if (index > 0xFFFF){
907                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
908                 }
909                 // Write the tag first
910                 writeU1(StringTag);
911                 // Then the string index
912                 writeU2(stringIndex);
913         }
914         return index;
915 }
916 /**
917  * This method returns the index into the constantPool 
918  * corresponding to the field binding aFieldBinding.
919  *
920  * @param FieldBinding aFieldBinding
921  * @return <CODE>int</CODE>
922  */
923 public int literalIndex(FieldBinding aFieldBinding) {
924         int index;
925         int nameAndTypeIndex;
926         int classIndex;
927         int indexWellKnownField;
928         if ((indexWellKnownField = indexOfWellKnownFields(aFieldBinding)) == -1) {
929                 if ((index = fieldCache.get(aFieldBinding)) < 0) {
930                         // The entry doesn't exit yet
931                         classIndex = literalIndex(aFieldBinding.declaringClass);
932                         nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
933                         index = fieldCache.put(aFieldBinding, currentIndex++);
934                         if (index > 0xFFFF){
935                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
936                         }
937                         writeU1(FieldRefTag);
938                         writeU2(classIndex);
939                         writeU2(nameAndTypeIndex);
940                 }
941         } else {
942                 if ((index = wellKnownFields[indexWellKnownField]) == 0) {
943                         // that field need to be inserted
944                         classIndex = literalIndex(aFieldBinding.declaringClass);
945                         nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
946                         index = wellKnownFields[indexWellKnownField] = currentIndex++;
947                         if (index > 0xFFFF){
948                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
949                         }
950                         writeU1(FieldRefTag);
951                         writeU2(classIndex);
952                         writeU2(nameAndTypeIndex);
953                 }
954         }
955         return index;
956 }
957 /**
958  * This method returns the index into the constantPool corresponding to the 
959  * method descriptor. It can be either an interface method reference constant
960  * or a method reference constant.
961  *
962  * @param MethodBinding aMethodBinding
963  * @return <CODE>int</CODE>
964  */
965 public int literalIndex(MethodBinding aMethodBinding) {
966         int index;
967         int nameAndTypeIndex;
968         int classIndex;
969         int indexWellKnownMethod;
970         if ((indexWellKnownMethod = indexOfWellKnownMethods(aMethodBinding)) == -1) {
971                 if (aMethodBinding.declaringClass.isInterface()) {
972                         // Lookinf into the interface method ref table
973                         if ((index = interfaceMethodCache.get(aMethodBinding)) < 0) {
974                                 classIndex = literalIndex(aMethodBinding.declaringClass);
975                                 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
976                                 index = interfaceMethodCache.put(aMethodBinding, currentIndex++);
977                                 if (index > 0xFFFF){
978                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
979                                 }
980                                 // Write the interface method ref constant into the constant pool
981                                 // First add the tag
982                                 writeU1(InterfaceMethodRefTag);
983                                 // Then write the class index
984                                 writeU2(classIndex);
985                                 // The write the nameAndType index
986                                 writeU2(nameAndTypeIndex);
987                         }
988                 } else {
989                         // Lookinf into the method ref table
990                         if ((index = methodCache.get(aMethodBinding)) < 0) {
991                                 classIndex = literalIndex(aMethodBinding.declaringClass);
992                                 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
993                                 index = methodCache.put(aMethodBinding, currentIndex++);
994                                 if (index > 0xFFFF){
995                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
996                                 }
997                                 // Write the method ref constant into the constant pool
998                                 // First add the tag
999                                 writeU1(MethodRefTag);
1000                                 // Then write the class index
1001                                 writeU2(classIndex);
1002                                 // The write the nameAndType index
1003                                 writeU2(nameAndTypeIndex);
1004                         }
1005                 }
1006         } else {
1007                 // This is a well known method
1008                 if ((index = wellKnownMethods[indexWellKnownMethod]) == 0) {
1009                         // this methods was not inserted yet
1010                         if (aMethodBinding.declaringClass.isInterface()) {
1011                                 // Lookinf into the interface method ref table
1012                                 classIndex = literalIndex(aMethodBinding.declaringClass);
1013                                 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
1014                                 index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
1015                                 if (index > 0xFFFF){
1016                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1017                                 }
1018                                 // Write the interface method ref constant into the constant pool
1019                                 // First add the tag
1020                                 writeU1(InterfaceMethodRefTag);
1021                                 // Then write the class index
1022                                 writeU2(classIndex);
1023                                 // The write the nameAndType index
1024                                 writeU2(nameAndTypeIndex);
1025                         } else {
1026                                 // Lookinf into the method ref table
1027                                 classIndex = literalIndex(aMethodBinding.declaringClass);
1028                                 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
1029                                 index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
1030                                 if (index > 0xFFFF){
1031                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1032                                 }
1033                                 // Write the method ref constant into the constant pool
1034                                 // First add the tag
1035                                 writeU1(MethodRefTag);
1036                                 // Then write the class index
1037                                 writeU2(classIndex);
1038                                 // The write the nameAndType index
1039                                 writeU2(nameAndTypeIndex);
1040                         }
1041                 }
1042         }
1043         return index;
1044 }
1045 /**
1046  * This method returns the index into the constantPool corresponding to the type descriptor.
1047  *
1048  * @param TypeBinding aTypeBinding
1049  * @return <CODE>int</CODE>
1050  */
1051 public int literalIndex(TypeBinding aTypeBinding) {
1052         int index;
1053         int nameIndex;
1054         int indexWellKnownType;
1055         if ((indexWellKnownType = indexOfWellKnownTypes(aTypeBinding)) == -1) {
1056                 if ((index = classCache.get(aTypeBinding)) < 0) {
1057                         // The entry doesn't exit yet
1058                         nameIndex = literalIndex(aTypeBinding.constantPoolName());
1059                         index = classCache.put(aTypeBinding, currentIndex++);
1060                         if (index > 0xFFFF){
1061                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1062                         }
1063                         writeU1(ClassTag);
1064                         // Then add the 8 bytes representing the long
1065                         writeU2(nameIndex);
1066                 }
1067         } else {
1068                 if ((index = wellKnownTypes[indexWellKnownType]) == 0) {
1069                         // Need to insert that binding
1070                         nameIndex = literalIndex(aTypeBinding.constantPoolName());
1071                         index = wellKnownTypes[indexWellKnownType] = currentIndex++;
1072                         if (index > 0xFFFF){
1073                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1074                         }
1075                         writeU1(ClassTag);
1076                         // Then add the 8 bytes representing the long
1077                         writeU2(nameIndex);
1078                 }
1079         }
1080         return index;
1081 }
1082 /**
1083  * This method returns the index into the constantPool corresponding 
1084  * nameAndType constant with nameIndex, typeIndex.
1085  *
1086  * @param int nameIndex
1087  * @param int nameIndex
1088  * @param org.eclipse.jdt.internal.compiler.lookup.FieldBinding a FieldBinding
1089  * @return <CODE>int</CODE>
1090  */
1091 public int literalIndexForFields(int nameIndex, int typeIndex, FieldBinding key) {
1092         int index;
1093         int indexOfWellKnownFieldNameAndType;
1094         if ((indexOfWellKnownFieldNameAndType = indexOfWellKnownFieldNameAndType(key)) == -1) {
1095                 // check if the entry already exists
1096                 if ((index = nameAndTypeCacheForFields.get(key)) == -1) {
1097                         // The entry doesn't exit yet
1098                         index = nameAndTypeCacheForFields.put(key, currentIndex++);
1099                         if (index > 0xFFFF){
1100                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1101                         }
1102                         writeU1(NameAndTypeTag);
1103                         writeU2(nameIndex);
1104                         writeU2(typeIndex);
1105                 }
1106         } else {
1107                 if ((index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType]) == 0) {
1108                         index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType] = currentIndex++;
1109                         if (index > 0xFFFF){
1110                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1111                         }
1112                         writeU1(NameAndTypeTag);
1113                         writeU2(nameIndex);
1114                         writeU2(typeIndex);
1115                 }
1116         }
1117         return index;
1118 }
1119 /**
1120  * This method returns the index into the constantPool corresponding to the type descriptor.
1121  *
1122  * @param TypeBinding aTypeBinding
1123  * @return <CODE>int</CODE>
1124  */
1125 public int literalIndexForJavaLangBoolean() {
1126         int index;
1127         if ((index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE]) == 0) {
1128                 int nameIndex;
1129                 // The entry doesn't exit yet
1130                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangBooleanConstantPoolName);
1131                 index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE] = currentIndex++;
1132                 if (index > 0xFFFF){
1133                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1134                 }
1135                 writeU1(ClassTag);
1136                 // Then add the 8 bytes representing the long
1137                 writeU2(nameIndex);
1138         }
1139         return index;
1140 }
1141 /**
1142  * This method returns the index into the constantPool 
1143  * corresponding to the field binding aFieldBinding.
1144  *
1145  * @return <CODE>int</CODE>
1146  */
1147 public int literalIndexForJavaLangBooleanTYPE() {
1148         int index;
1149         if ((index = wellKnownFields[TYPE_BOOLEAN_FIELD]) == 0) {
1150                 int nameAndTypeIndex;
1151                 int classIndex;
1152                 // The entry doesn't exit yet
1153                 classIndex = literalIndexForJavaLangBoolean();
1154                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1155                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1156                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1157                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1158                         writeU1(NameAndTypeTag);
1159                         writeU2(nameIndex);
1160                         writeU2(typeIndex);
1161                 }
1162                 index = wellKnownFields[TYPE_BOOLEAN_FIELD] = currentIndex++;
1163                 if (index > 0xFFFF){
1164                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1165                 }
1166                 writeU1(FieldRefTag);
1167                 writeU2(classIndex);
1168                 writeU2(nameAndTypeIndex);
1169         }
1170         return index;
1171 }
1172 /**
1173  * This method returns the index into the constantPool corresponding to the type descriptor.
1174  *
1175  * @param TypeBinding aTypeBinding
1176  * @return <CODE>int</CODE>
1177  */
1178 public int literalIndexForJavaLangByte() {
1179         int index;
1180         if ((index = wellKnownTypes[JAVA_LANG_BYTE_TYPE]) == 0) {
1181                 int nameIndex;
1182                 // The entry doesn't exit yet
1183                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangByteConstantPoolName);
1184                 index = wellKnownTypes[JAVA_LANG_BYTE_TYPE] = currentIndex++;
1185                 if (index > 0xFFFF){
1186                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1187                 }
1188                 writeU1(ClassTag);
1189                 // Then add the 8 bytes representing the long
1190                 writeU2(nameIndex);
1191         }
1192         return index;
1193 }
1194 /**
1195  * This method returns the index into the constantPool 
1196  * corresponding to the field binding aFieldBinding.
1197  *
1198  * @return <CODE>int</CODE>
1199  */
1200 public int literalIndexForJavaLangByteTYPE() {
1201         int index;
1202         if ((index = wellKnownFields[TYPE_BYTE_FIELD]) == 0) {
1203                 int nameAndTypeIndex;
1204                 int classIndex;
1205                 // The entry doesn't exit yet
1206                 classIndex = literalIndexForJavaLangByte();
1207                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1208                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1209                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1210                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1211                         writeU1(NameAndTypeTag);
1212                         writeU2(nameIndex);
1213                         writeU2(typeIndex);
1214                 }
1215                 index = wellKnownFields[TYPE_BYTE_FIELD] = currentIndex++;
1216                 if (index > 0xFFFF){
1217                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1218                 }
1219                 writeU1(FieldRefTag);
1220                 writeU2(classIndex);
1221                 writeU2(nameAndTypeIndex);
1222         }
1223         return index;
1224 }
1225 /**
1226  * This method returns the index into the constantPool corresponding to the type descriptor.
1227  *
1228  * @param TypeBinding aTypeBinding
1229  * @return <CODE>int</CODE>
1230  */
1231 public int literalIndexForJavaLangCharacter() {
1232         int index;
1233         if ((index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE]) == 0) {
1234                 int nameIndex;
1235                 // The entry doesn't exit yet
1236                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangCharacterConstantPoolName);
1237                 index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE] = currentIndex++;
1238                 if (index > 0xFFFF){
1239                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1240                 }
1241                 writeU1(ClassTag);
1242                 // Then add the 8 bytes representing the long
1243                 writeU2(nameIndex);
1244         }
1245         return index;
1246 }
1247 /**
1248  * This method returns the index into the constantPool 
1249  * corresponding to the field binding aFieldBinding.
1250  *
1251  * @return <CODE>int</CODE>
1252  */
1253 public int literalIndexForJavaLangCharacterTYPE() {
1254         int index;
1255         if ((index = wellKnownFields[TYPE_CHARACTER_FIELD]) == 0) {
1256                 int nameAndTypeIndex;
1257                 int classIndex;
1258                 // The entry doesn't exit yet
1259                 classIndex = literalIndexForJavaLangCharacter();
1260                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1261                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1262                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1263                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1264                         writeU1(NameAndTypeTag);
1265                         writeU2(nameIndex);
1266                         writeU2(typeIndex);
1267                 }
1268                 index = wellKnownFields[TYPE_CHARACTER_FIELD] = currentIndex++;
1269                 if (index > 0xFFFF){
1270                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1271                 }
1272                 writeU1(FieldRefTag);
1273                 writeU2(classIndex);
1274                 writeU2(nameAndTypeIndex);
1275         }
1276         return index;
1277 }
1278 /**
1279  * This method returns the index into the constantPool corresponding to the type descriptor.
1280  *
1281  * @param TypeBinding aTypeBinding
1282  * @return <CODE>int</CODE>
1283  */
1284 public int literalIndexForJavaLangClass() {
1285         int index;
1286         if ((index = wellKnownTypes[JAVA_LANG_CLASS_TYPE]) == 0) {
1287                 int nameIndex;
1288                 // The entry doesn't exit yet
1289                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassConstantPoolName);
1290                 index = wellKnownTypes[JAVA_LANG_CLASS_TYPE] = currentIndex++;
1291                 if (index > 0xFFFF){
1292                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1293                 }
1294                 writeU1(ClassTag);
1295                 // Then add the 8 bytes representing the long
1296                 writeU2(nameIndex);
1297         }
1298         return index;
1299 }
1300 /**
1301  * This method returns the index into the constantPool corresponding to the 
1302  * method descriptor. It can be either an interface method reference constant
1303  * or a method reference constant.
1304  *
1305  * @return <CODE>int</CODE>
1306  */
1307 public int literalIndexForJavaLangClassForName() {
1308         int index;
1309         int nameAndTypeIndex;
1310         int classIndex;
1311         // Looking into the method ref table
1312         if ((index = wellKnownMethods[FORNAME_CLASS_METHOD]) == 0) {
1313                 classIndex = literalIndexForJavaLangClass();
1314                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE]) == 0) {
1315                         int nameIndex = literalIndex(QualifiedNamesConstants.ForName);
1316                         int typeIndex = literalIndex(QualifiedNamesConstants.ForNameSignature);
1317                         nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE] = currentIndex++;
1318                         writeU1(NameAndTypeTag);
1319                         writeU2(nameIndex);
1320                         writeU2(typeIndex);
1321                 }
1322                 index = wellKnownMethods[FORNAME_CLASS_METHOD] = currentIndex++;
1323                 if (index > 0xFFFF){
1324                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1325                 }
1326                 // Write the method ref constant into the constant pool
1327                 // First add the tag
1328                 writeU1(MethodRefTag);
1329                 // Then write the class index
1330                 writeU2(classIndex);
1331                 // The write the nameAndType index
1332                 writeU2(nameAndTypeIndex);
1333         }
1334         return index;
1335 }
1336 /**
1337  * This method returns the index into the constantPool corresponding to the 
1338  * method descriptor. It can be either an interface method reference constant
1339  * or a method reference constant.
1340  *
1341  * @return <CODE>int</CODE>
1342  */
1343 public int literalIndexForJavaLangClassGetConstructor() {
1344         int index;
1345         int nameAndTypeIndex;
1346         int classIndex;
1347         // Looking into the method ref table
1348         if ((index = wellKnownMethods[GETCONSTRUCTOR_CLASS_METHOD]) == 0) {
1349                 classIndex = literalIndexForJavaLangClass();
1350                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCONSTRUCTOR_METHOD_NAME_AND_TYPE]) == 0) {
1351                         int nameIndex = literalIndex(QualifiedNamesConstants.GetConstructor);
1352                         int typeIndex = literalIndex(QualifiedNamesConstants.GetConstructorSignature);
1353                         nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCONSTRUCTOR_METHOD_NAME_AND_TYPE] = currentIndex++;
1354                         writeU1(NameAndTypeTag);
1355                         writeU2(nameIndex);
1356                         writeU2(typeIndex);
1357                 }
1358                 index = wellKnownMethods[GETCONSTRUCTOR_CLASS_METHOD] = currentIndex++;
1359                 if (index > 0xFFFF){
1360                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1361                 }
1362                 // Write the method ref constant into the constant pool
1363                 // First add the tag
1364                 writeU1(MethodRefTag);
1365                 // Then write the class index
1366                 writeU2(classIndex);
1367                 // The write the nameAndType index
1368                 writeU2(nameAndTypeIndex);
1369         }
1370         return index;
1371 }
1372 /**
1373  * This method returns the index into the constantPool corresponding to the 
1374  * method descriptor. It can be either an interface method reference constant
1375  * or a method reference constant.
1376  *
1377  * @return <CODE>int</CODE>
1378  */
1379 public int literalIndexForJavaLangClassDesiredAssertionStatus() {
1380         int index;
1381         int nameAndTypeIndex;
1382         int classIndex;
1383         // Looking into the method ref table
1384         if ((index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD]) == 0) {
1385                 classIndex = literalIndexForJavaLangClass();
1386                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE]) == 0) {
1387                         int nameIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatus);
1388                         int typeIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatusSignature);
1389                         nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE] = currentIndex++;
1390                         writeU1(NameAndTypeTag);
1391                         writeU2(nameIndex);
1392                         writeU2(typeIndex);
1393                 }
1394                 index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD] = currentIndex++;
1395                 if (index > 0xFFFF){
1396                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1397                 }
1398                 // Write the method ref constant into the constant pool
1399                 // First add the tag
1400                 writeU1(MethodRefTag);
1401                 // Then write the class index
1402                 writeU2(classIndex);
1403                 // The write the nameAndType index
1404                 writeU2(nameAndTypeIndex);
1405         }
1406         return index;
1407 }
1408 /**
1409  * This method returns the index into the constantPool corresponding to the type descriptor.
1410  *
1411  * @param TypeBinding aTypeBinding
1412  * @return <CODE>int</CODE>
1413  */
1414 public int literalIndexForJavaLangClassNotFoundException() {
1415         int index;
1416         if ((index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE]) == 0) {
1417                 int nameIndex;
1418                 // The entry doesn't exit yet
1419                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassNotFoundExceptionConstantPoolName);
1420                 index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE] = currentIndex++;
1421                 if (index > 0xFFFF){
1422                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1423                 }
1424                 writeU1(ClassTag);
1425                 // Then add the 8 bytes representing the long
1426                 writeU2(nameIndex);
1427         }
1428         return index;
1429 }
1430 /**
1431  * This method returns the index into the constantPool corresponding to the type descriptor.
1432  *
1433  * @param TypeBinding aTypeBinding
1434  * @return <CODE>int</CODE>
1435  */
1436 public int literalIndexForJavaLangDouble() {
1437         int index;
1438         if ((index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE]) == 0) {
1439                 int nameIndex;
1440                 // The entry doesn't exit yet
1441                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangDoubleConstantPoolName);
1442                 index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE] = currentIndex++;
1443                 if (index > 0xFFFF){
1444                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1445                 }
1446                 writeU1(ClassTag);
1447                 // Then add the 8 bytes representing the long
1448                 writeU2(nameIndex);
1449         }
1450         return index;
1451 }
1452 /**
1453  * This method returns the index into the constantPool 
1454  * corresponding to the field binding aFieldBinding.
1455  *
1456  * @return <CODE>int</CODE>
1457  */
1458 public int literalIndexForJavaLangDoubleTYPE() {
1459         int index;
1460         if ((index = wellKnownFields[TYPE_DOUBLE_FIELD]) == 0) {
1461                 int nameAndTypeIndex;
1462                 int classIndex;
1463                 // The entry doesn't exit yet
1464                 classIndex = literalIndexForJavaLangDouble();
1465                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1466                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1467                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1468                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1469                         writeU1(NameAndTypeTag);
1470                         writeU2(nameIndex);
1471                         writeU2(typeIndex);
1472                 }
1473                 index = wellKnownFields[TYPE_DOUBLE_FIELD] = currentIndex++;
1474                 if (index > 0xFFFF){
1475                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1476                 }
1477                 writeU1(FieldRefTag);
1478                 writeU2(classIndex);
1479                 writeU2(nameAndTypeIndex);
1480         }
1481         return index;
1482 }
1483 /**
1484  * This method returns the index into the constantPool corresponding to the type descriptor.
1485  *
1486  * @param TypeBinding aTypeBinding
1487  * @return <CODE>int</CODE>
1488  */
1489 public int literalIndexForJavaLangError() {
1490         int index;
1491         if ((index = wellKnownTypes[JAVA_LANG_ERROR_TYPE]) == 0) {
1492                 int nameIndex;
1493                 // The entry doesn't exit yet
1494                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangErrorConstantPoolName);
1495                 index = wellKnownTypes[JAVA_LANG_ERROR_TYPE] = currentIndex++;
1496                 if (index > 0xFFFF){
1497                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1498                 }
1499                 writeU1(ClassTag);
1500                 // Then add the 8 bytes representing the long
1501                 writeU2(nameIndex);
1502         }
1503         return index;
1504 }
1505 /**
1506  * This method returns the index into the constantPool corresponding to the 
1507  * method descriptor. It can be either an interface method reference constant
1508  * or a method reference constant.
1509  *
1510  * @return <CODE>int</CODE>
1511  */
1512 public int literalIndexForJavaLangErrorConstructor() {
1513         int index;
1514         int nameAndTypeIndex;
1515         int classIndex;
1516         // Looking into the method ref table
1517         if ((index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD]) == 0) {
1518                 classIndex = literalIndexForJavaLangError();
1519                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
1520                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1521                         int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
1522                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
1523                         writeU1(NameAndTypeTag);
1524                         writeU2(nameIndex);
1525                         writeU2(typeIndex);
1526                 }
1527                 index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD] = currentIndex++;
1528                 if (index > 0xFFFF){
1529                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1530                 }
1531                 // Write the method ref constant into the constant pool
1532                 // First add the tag
1533                 writeU1(MethodRefTag);
1534                 // Then write the class index
1535                 writeU2(classIndex);
1536                 // The write the nameAndType index
1537                 writeU2(nameAndTypeIndex);
1538         }
1539         return index;
1540 }
1541 public int literalIndexForJavaLangException() {
1542         int index;
1543         if ((index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE]) == 0) {
1544                 // The entry doesn't exit yet
1545                 int nameIndex = literalIndex(QualifiedNamesConstants.JavaLangExceptionConstantPoolName);
1546                 index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE] = currentIndex++;
1547                 if (index > 0xFFFF){
1548                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1549                 }
1550                 writeU1(ClassTag);
1551                 // Then add the 8 bytes representing the long
1552                 writeU2(nameIndex);
1553         }
1554         return index;
1555 }
1556 /**
1557  * This method returns the index into the constantPool corresponding to the type descriptor.
1558  *
1559  * @param TypeBinding aTypeBinding
1560  * @return <CODE>int</CODE>
1561  */
1562 public int literalIndexForJavaLangFloat() {
1563         int index;
1564         if ((index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE]) == 0) {
1565                 int nameIndex;
1566                 // The entry doesn't exit yet
1567                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangFloatConstantPoolName);
1568                 index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE] = currentIndex++;
1569                 if (index > 0xFFFF){
1570                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1571                 }
1572                 writeU1(ClassTag);
1573                 // Then add the 8 bytes representing the long
1574                 writeU2(nameIndex);
1575         }
1576         return index;
1577 }
1578 /**
1579  * This method returns the index into the constantPool 
1580  * corresponding to the field binding aFieldBinding.
1581  *
1582  * @return <CODE>int</CODE>
1583  */
1584 public int literalIndexForJavaLangFloatTYPE() {
1585         int index;
1586         if ((index = wellKnownFields[TYPE_FLOAT_FIELD]) == 0) {
1587                 int nameAndTypeIndex;
1588                 int classIndex;
1589                 // The entry doesn't exit yet
1590                 classIndex = literalIndexForJavaLangFloat();
1591                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1592                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1593                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1594                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1595                         writeU1(NameAndTypeTag);
1596                         writeU2(nameIndex);
1597                         writeU2(typeIndex);
1598                 }
1599                 index = wellKnownFields[TYPE_FLOAT_FIELD] = currentIndex++;
1600                 if (index > 0xFFFF){
1601                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1602                 }
1603                 writeU1(FieldRefTag);
1604                 writeU2(classIndex);
1605                 writeU2(nameAndTypeIndex);
1606         }
1607         return index;
1608 }
1609 /**
1610  * This method returns the index into the constantPool corresponding to the type descriptor.
1611  *
1612  * @param TypeBinding aTypeBinding
1613  * @return <CODE>int</CODE>
1614  */
1615 public int literalIndexForJavaLangInteger() {
1616         int index;
1617         if ((index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE]) == 0) {
1618                 int nameIndex;
1619                 // The entry doesn't exit yet
1620                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangIntegerConstantPoolName);
1621                 index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE] = currentIndex++;
1622                 if (index > 0xFFFF){
1623                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1624                 }
1625                 writeU1(ClassTag);
1626                 // Then add the 8 bytes representing the long
1627                 writeU2(nameIndex);
1628         }
1629         return index;
1630 }
1631 /**
1632  * This method returns the index into the constantPool 
1633  * corresponding to the field binding aFieldBinding.
1634  *
1635  * @return <CODE>int</CODE>
1636  */
1637 public int literalIndexForJavaLangIntegerTYPE() {
1638         int index;
1639         if ((index = wellKnownFields[TYPE_INTEGER_FIELD]) == 0) {
1640                 int nameAndTypeIndex;
1641                 int classIndex;
1642                 // The entry doesn't exit yet
1643                 classIndex = literalIndexForJavaLangInteger();
1644                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1645                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1646                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1647                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1648                         writeU1(NameAndTypeTag);
1649                         writeU2(nameIndex);
1650                         writeU2(typeIndex);
1651                 }
1652                 index = wellKnownFields[TYPE_INTEGER_FIELD] = currentIndex++;
1653                 if (index > 0xFFFF){
1654                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1655                 }
1656                 writeU1(FieldRefTag);
1657                 writeU2(classIndex);
1658                 writeU2(nameAndTypeIndex);
1659         }
1660         return index;
1661 }
1662 /**
1663  * This method returns the index into the constantPool corresponding to the type descriptor.
1664  *
1665  * @param TypeBinding aTypeBinding
1666  * @return <CODE>int</CODE>
1667  */
1668 public int literalIndexForJavaLangLong() {
1669         int index;
1670         if ((index = wellKnownTypes[JAVA_LANG_LONG_TYPE]) == 0) {
1671                 int nameIndex;
1672                 // The entry doesn't exit yet
1673                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangLongConstantPoolName);
1674                 index = wellKnownTypes[JAVA_LANG_LONG_TYPE] = currentIndex++;
1675                 if (index > 0xFFFF){
1676                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1677                 }
1678                 writeU1(ClassTag);
1679                 // Then add the 8 bytes representing the long
1680                 writeU2(nameIndex);
1681         }
1682         return index;
1683 }
1684 /**
1685  * This method returns the index into the constantPool 
1686  * corresponding to the field binding aFieldBinding.
1687  *
1688  * @return <CODE>int</CODE>
1689  */
1690 public int literalIndexForJavaLangLongTYPE() {
1691         int index;
1692         if ((index = wellKnownFields[TYPE_LONG_FIELD]) == 0) {
1693                 int nameAndTypeIndex;
1694                 int classIndex;
1695                 // The entry doesn't exit yet
1696                 classIndex = literalIndexForJavaLangLong();
1697                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1698                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1699                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1700                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1701                         writeU1(NameAndTypeTag);
1702                         writeU2(nameIndex);
1703                         writeU2(typeIndex);
1704                 }
1705                 index = wellKnownFields[TYPE_LONG_FIELD] = currentIndex++;
1706                 if (index > 0xFFFF){
1707                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1708                 }
1709                 writeU1(FieldRefTag);
1710                 writeU2(classIndex);
1711                 writeU2(nameAndTypeIndex);
1712         }
1713         return index;
1714 }
1715 /**
1716  * This method returns the index into the constantPool corresponding to the type descriptor.
1717  *
1718  * @param TypeBinding aTypeBinding
1719  * @return <CODE>int</CODE>
1720  */
1721 public int literalIndexForJavaLangNoClassDefFoundError() {
1722         int index;
1723         if ((index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE]) == 0) {
1724                 int nameIndex;
1725                 // The entry doesn't exit yet
1726                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangNoClassDefFoundErrorConstantPoolName);
1727                 index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE] = currentIndex++;
1728                 if (index > 0xFFFF){
1729                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1730                 }
1731                 writeU1(ClassTag);
1732                 // Then add the 8 bytes representing the long
1733                 writeU2(nameIndex);
1734         }
1735         return index;
1736 }
1737
1738 /**
1739  * This method returns the index into the constantPool corresponding to the type descriptor.
1740  *
1741  * @param TypeBinding aTypeBinding
1742  * @return <CODE>int</CODE>
1743  */
1744 public int literalIndexForJavaLangAssertionError() {
1745         int index;
1746         if ((index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE]) == 0) {
1747                 int nameIndex;
1748                 // The entry doesn't exit yet
1749                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangAssertionErrorConstantPoolName);
1750                 index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE] = currentIndex++;
1751                 if (index > 0xFFFF){
1752                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1753                 }
1754                 writeU1(ClassTag);
1755                 // Then add the 8 bytes representing the long
1756                 writeU2(nameIndex);
1757         }
1758         return index;
1759 }
1760
1761 /**
1762  * This method returns the index into the constantPool corresponding to the type descriptor.
1763  *
1764  * @param TypeBinding aTypeBinding
1765  * @return <CODE>int</CODE>
1766  */
1767 public int literalIndexForJavaLangAssertionErrorConstructor(int typeBindingID) {
1768         int index = 0;
1769         int nameAndTypeIndex = 0;
1770         int classIndex = 0;
1771         switch (typeBindingID) {
1772                 case T_int :
1773                 case T_byte :
1774                 case T_short :
1775                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD]) == 0) {
1776                                 classIndex = literalIndexForJavaLangAssertionError();
1777                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE]) == 0) {
1778                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1779                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorIntConstrSignature);
1780                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
1781                                         writeU1(NameAndTypeTag);
1782                                         writeU2(nameIndex);
1783                                         writeU2(typeIndex);
1784                                 }
1785                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD] = currentIndex++;
1786                                 if (index > 0xFFFF){
1787                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1788                                 }
1789                                 // Write the method ref constant into the constant pool
1790                                 // First add the tag
1791                                 writeU1(MethodRefTag);
1792                                 // Then write the class index
1793                                 writeU2(classIndex);
1794                                 // The write the nameAndType index
1795                                 writeU2(nameAndTypeIndex);
1796                         }
1797                         break;
1798                 case T_long :
1799                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD]) == 0) {
1800                                 classIndex = literalIndexForJavaLangAssertionError();
1801                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE]) == 0) {
1802                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1803                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorLongConstrSignature);
1804                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
1805                                         writeU1(NameAndTypeTag);
1806                                         writeU2(nameIndex);
1807                                         writeU2(typeIndex);
1808                                 }
1809                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD] = currentIndex++;
1810                                 if (index > 0xFFFF){
1811                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1812                                 }
1813                                 // Write the method ref constant into the constant pool
1814                                 // First add the tag
1815                                 writeU1(MethodRefTag);
1816                                 // Then write the class index
1817                                 writeU2(classIndex);
1818                                 // The write the nameAndType index
1819                                 writeU2(nameAndTypeIndex);
1820                         }
1821                         break;
1822                 case T_float :
1823                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD]) == 0) {
1824                                 classIndex = literalIndexForJavaLangAssertionError();
1825                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
1826                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1827                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorFloatConstrSignature);
1828                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
1829                                         writeU1(NameAndTypeTag);
1830                                         writeU2(nameIndex);
1831                                         writeU2(typeIndex);
1832                                 }
1833                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD] = currentIndex++;
1834                                 if (index > 0xFFFF){
1835                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1836                                 }
1837                                 // Write the method ref constant into the constant pool
1838                                 // First add the tag
1839                                 writeU1(MethodRefTag);
1840                                 // Then write the class index
1841                                 writeU2(classIndex);
1842                                 // The write the nameAndType index
1843                                 writeU2(nameAndTypeIndex);
1844                         }
1845                         break;
1846                 case T_double :
1847                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD]) == 0) {
1848                                 classIndex = literalIndexForJavaLangAssertionError();
1849                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
1850                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1851                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorDoubleConstrSignature);
1852                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
1853                                         writeU1(NameAndTypeTag);
1854                                         writeU2(nameIndex);
1855                                         writeU2(typeIndex);
1856                                 }
1857                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD] = currentIndex++;
1858                                 if (index > 0xFFFF){
1859                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1860                                 }
1861                                 // Write the method ref constant into the constant pool
1862                                 // First add the tag
1863                                 writeU1(MethodRefTag);
1864                                 // Then write the class index
1865                                 writeU2(classIndex);
1866                                 // The write the nameAndType index
1867                                 writeU2(nameAndTypeIndex);
1868                         }
1869                         break;
1870                 case T_char :
1871                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD]) == 0) {
1872                                 classIndex = literalIndexForJavaLangAssertionError();
1873                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
1874                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1875                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorCharConstrSignature);
1876                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
1877                                         writeU1(NameAndTypeTag);
1878                                         writeU2(nameIndex);
1879                                         writeU2(typeIndex);
1880                                 }
1881                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD] = currentIndex++;
1882                                 if (index > 0xFFFF){
1883                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1884                                 }
1885                                 // Write the method ref constant into the constant pool
1886                                 // First add the tag
1887                                 writeU1(MethodRefTag);
1888                                 // Then write the class index
1889                                 writeU2(classIndex);
1890                                 // The write the nameAndType index
1891                                 writeU2(nameAndTypeIndex);
1892                         }
1893                         break;
1894                 case T_boolean :
1895                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD]) == 0) {
1896                                 classIndex = literalIndexForJavaLangAssertionError();
1897                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
1898                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1899                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorBooleanConstrSignature);
1900                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
1901                                         writeU1(NameAndTypeTag);
1902                                         writeU2(nameIndex);
1903                                         writeU2(typeIndex);
1904                                 }
1905                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD] = currentIndex++;
1906                                 if (index > 0xFFFF){
1907                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1908                                 }
1909                                 // Write the method ref constant into the constant pool
1910                                 // First add the tag
1911                                 writeU1(MethodRefTag);
1912                                 // Then write the class index
1913                                 writeU2(classIndex);
1914                                 // The write the nameAndType index
1915                                 writeU2(nameAndTypeIndex);
1916                         }
1917                         break;
1918                 //case T_Object :
1919                 //case T_String :
1920                 //case T_null :
1921                 default : 
1922                         if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD]) == 0) {
1923                                 classIndex = literalIndexForJavaLangAssertionError();
1924                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
1925                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1926                                         int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorObjectConstrSignature);
1927                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
1928                                         writeU1(NameAndTypeTag);
1929                                         writeU2(nameIndex);
1930                                         writeU2(typeIndex);
1931                                 }
1932                                 index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD] = currentIndex++;
1933                                 if (index > 0xFFFF){
1934                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1935                                 }
1936                                 // Write the method ref constant into the constant pool
1937                                 // First add the tag
1938                                 writeU1(MethodRefTag);
1939                                 // Then write the class index
1940                                 writeU2(classIndex);
1941                                 // The write the nameAndType index
1942                                 writeU2(nameAndTypeIndex);
1943                         }
1944         }
1945         return index;
1946 }
1947
1948 /**
1949  * This method returns the index into the constantPool corresponding to the 
1950  * method descriptor. It can be either an interface method reference constant
1951  * or a method reference constant.
1952  *
1953  * @return <CODE>int</CODE>
1954  */
1955 public int literalIndexForJavaLangAssertionErrorDefaultConstructor() {
1956         int index;
1957         int nameAndTypeIndex;
1958         int classIndex;
1959         // Looking into the method ref table
1960         if ((index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD]) == 0) {
1961                 classIndex = literalIndexForJavaLangAssertionError();
1962                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
1963                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1964                         int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
1965                         nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
1966                         writeU1(NameAndTypeTag);
1967                         writeU2(nameIndex);
1968                         writeU2(typeIndex);
1969                 }
1970                 index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD] = currentIndex++;
1971                 if (index > 0xFFFF){
1972                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1973                 }
1974                 // Write the method ref constant into the constant pool
1975                 // First add the tag
1976                 writeU1(MethodRefTag);
1977                 // Then write the class index
1978                 writeU2(classIndex);
1979                 // The write the nameAndType index
1980                 writeU2(nameAndTypeIndex);
1981         }
1982         return index;
1983 }
1984
1985
1986 /**
1987  * This method returns the index into the constantPool corresponding to the 
1988  * method descriptor. It can be either an interface method reference constant
1989  * or a method reference constant.
1990  *
1991  * @return <CODE>int</CODE>
1992  */
1993 public int literalIndexForJavaLangNoClassDefFoundErrorStringConstructor() {
1994         int index;
1995         int nameAndTypeIndex;
1996         int classIndex;
1997         // Looking into the method ref table
1998         if ((index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD]) == 0) {
1999                 classIndex = literalIndexForJavaLangNoClassDefFoundError();
2000                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2001                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2002                         int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
2003                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2004                         writeU1(NameAndTypeTag);
2005                         writeU2(nameIndex);
2006                         writeU2(typeIndex);
2007                 }
2008                 index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD] = currentIndex++;
2009                 if (index > 0xFFFF){
2010                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2011                 }
2012                 // Write the method ref constant into the constant pool
2013                 // First add the tag
2014                 writeU1(MethodRefTag);
2015                 // Then write the class index
2016                 writeU2(classIndex);
2017                 // The write the nameAndType index
2018                 writeU2(nameAndTypeIndex);
2019         }
2020         return index;
2021 }
2022 /**
2023  * This method returns the index into the constantPool corresponding to the type descriptor.
2024  *
2025  * @param TypeBinding aTypeBinding
2026  * @return <CODE>int</CODE>
2027  */
2028 public int literalIndexForJavaLangObject() {
2029         int index;
2030         if ((index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE]) == 0) {
2031                 int nameIndex;
2032                 // The entry doesn't exit yet
2033                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangObjectConstantPoolName);
2034                 index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE] = currentIndex++;
2035                 if (index > 0xFFFF){
2036                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2037                 }
2038                 writeU1(ClassTag);
2039                 // Then add the 8 bytes representing the long
2040                 writeU2(nameIndex);
2041         }
2042         return index;
2043 }
2044 /**
2045  * This method returns the index into the constantPool corresponding to the type descriptor.
2046  *
2047  * @param TypeBinding aTypeBinding
2048  * @return <CODE>int</CODE>
2049  */
2050 public int literalIndexForJavaLangReflectConstructor() {
2051         int index;
2052         if ((index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE]) == 0) {
2053                 int nameIndex;
2054                 // The entry doesn't exit yet
2055                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangReflectConstructor);
2056                 index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE] = currentIndex++;
2057                 if (index > 0xFFFF){
2058                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2059                 }
2060                 writeU1(ClassTag);
2061                 // Then add the 8 bytes representing the long
2062                 writeU2(nameIndex);
2063         }
2064         return index;
2065 }
2066 public int literalIndexForJavaLangReflectConstructorNewInstance() {
2067         int index;
2068         int nameAndTypeIndex;
2069         int classIndex;
2070         // Looking into the method ref table
2071         if ((index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD]) == 0) {
2072                 classIndex = literalIndexForJavaLangReflectConstructor();
2073                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE]) == 0) {
2074                         int nameIndex = literalIndex(QualifiedNamesConstants.NewInstance);
2075                         int typeIndex = literalIndex(QualifiedNamesConstants.NewInstanceSignature);
2076                         nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE] = currentIndex++;
2077                         writeU1(NameAndTypeTag);
2078                         writeU2(nameIndex);
2079                         writeU2(typeIndex);
2080                 }
2081                 index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD] = currentIndex++;
2082                 if (index > 0xFFFF){
2083                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2084                 }
2085                 // Write the method ref constant into the constant pool
2086                 // First add the tag
2087                 writeU1(MethodRefTag);
2088                 // Then write the class index
2089                 writeU2(classIndex);
2090                 // The write the nameAndType index
2091                 writeU2(nameAndTypeIndex);
2092         }
2093         return index;
2094 }
2095 /**
2096  * This method returns the index into the constantPool corresponding to the type descriptor.
2097  *
2098  * @param TypeBinding aTypeBinding
2099  * @return <CODE>int</CODE>
2100  */
2101 public int literalIndexForJavaLangShort() {
2102         int index;
2103         if ((index = wellKnownTypes[JAVA_LANG_SHORT_TYPE]) == 0) {
2104                 int nameIndex;
2105                 // The entry doesn't exit yet
2106                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangShortConstantPoolName);
2107                 index = wellKnownTypes[JAVA_LANG_SHORT_TYPE] = currentIndex++;
2108                 if (index > 0xFFFF){
2109                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2110                 }
2111                 writeU1(ClassTag);
2112                 // Then add the 8 bytes representing the long
2113                 writeU2(nameIndex);
2114         }
2115         return index;
2116 }
2117 /**
2118  * This method returns the index into the constantPool 
2119  * corresponding to the field binding aFieldBinding.
2120  *
2121  * @return <CODE>int</CODE>
2122  */
2123 public int literalIndexForJavaLangShortTYPE() {
2124         int index;
2125         if ((index = wellKnownFields[TYPE_SHORT_FIELD]) == 0) {
2126                 int nameAndTypeIndex;
2127                 int classIndex;
2128                 // The entry doesn't exit yet
2129                 classIndex = literalIndexForJavaLangShort();
2130                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
2131                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
2132                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
2133                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
2134                         writeU1(NameAndTypeTag);
2135                         writeU2(nameIndex);
2136                         writeU2(typeIndex);
2137                 }
2138                 index = wellKnownFields[TYPE_SHORT_FIELD] = currentIndex++;
2139                 if (index > 0xFFFF){
2140                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2141                 }
2142                 writeU1(FieldRefTag);
2143                 writeU2(classIndex);
2144                 writeU2(nameAndTypeIndex);
2145         }
2146         return index;
2147 }
2148 /**
2149  * This method returns the index into the constantPool corresponding to the type descriptor.
2150  *
2151  * @param TypeBinding aTypeBinding
2152  * @return <CODE>int</CODE>
2153  */
2154 public int literalIndexForJavaLangString() {
2155         int index;
2156         if ((index = wellKnownTypes[JAVA_LANG_STRING_TYPE]) == 0) {
2157                 int nameIndex;
2158                 // The entry doesn't exit yet
2159                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringConstantPoolName);
2160                 index = wellKnownTypes[JAVA_LANG_STRING_TYPE] = currentIndex++;
2161                 if (index > 0xFFFF){
2162                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2163                 }
2164                 writeU1(ClassTag);
2165                 // Then add the 8 bytes representing the long
2166                 writeU2(nameIndex);
2167         }
2168         return index;
2169 }
2170 /**
2171  * This method returns the index into the constantPool corresponding to the type descriptor.
2172  *
2173  * @param TypeBinding aTypeBinding
2174  * @return <CODE>int</CODE>
2175  */
2176 public int literalIndexForJavaLangStringBuffer() {
2177         int index;
2178         if ((index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE]) == 0) {
2179                 int nameIndex;
2180                 // The entry doesn't exit yet
2181                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringBufferConstantPoolName);
2182                 index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE] = currentIndex++;
2183                 if (index > 0xFFFF){
2184                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2185                 }
2186                 writeU1(ClassTag);
2187                 // Then add the 8 bytes representing the long
2188                 writeU2(nameIndex);
2189         }
2190         return index;
2191 }
2192 /**
2193  * This method returns the index into the constantPool corresponding to the 
2194  * method descriptor. It can be either an interface method reference constant
2195  * or a method reference constant.
2196  *
2197  * @return <CODE>int</CODE>
2198  */
2199 public int literalIndexForJavaLangStringBufferAppend(int typeID) {
2200         int index = 0;
2201         int nameAndTypeIndex = 0;
2202         int classIndex = 0;
2203         switch (typeID) {
2204                 case T_int :
2205                 case T_byte :
2206                 case T_short :
2207                         if ((index = wellKnownMethods[APPEND_INT_METHOD]) == 0) {
2208                                 classIndex = literalIndexForJavaLangStringBuffer();
2209                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE]) == 0) {
2210                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2211                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendIntSignature);
2212                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
2213                                         writeU1(NameAndTypeTag);
2214                                         writeU2(nameIndex);
2215                                         writeU2(typeIndex);
2216                                 }
2217                                 index = wellKnownMethods[APPEND_INT_METHOD] = currentIndex++;
2218                                 if (index > 0xFFFF){
2219                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2220                                 }
2221                                 // Write the method ref constant into the constant pool
2222                                 // First add the tag
2223                                 writeU1(MethodRefTag);
2224                                 // Then write the class index
2225                                 writeU2(classIndex);
2226                                 // The write the nameAndType index
2227                                 writeU2(nameAndTypeIndex);
2228                         }
2229                         break;
2230                 case T_long :
2231                         if ((index = wellKnownMethods[APPEND_LONG_METHOD]) == 0) {
2232                                 classIndex = literalIndexForJavaLangStringBuffer();
2233                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE]) == 0) {
2234                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2235                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendLongSignature);
2236                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
2237                                         writeU1(NameAndTypeTag);
2238                                         writeU2(nameIndex);
2239                                         writeU2(typeIndex);
2240                                 }
2241                                 index = wellKnownMethods[APPEND_LONG_METHOD] = currentIndex++;
2242                                 if (index > 0xFFFF){
2243                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2244                                 }
2245                                 // Write the method ref constant into the constant pool
2246                                 // First add the tag
2247                                 writeU1(MethodRefTag);
2248                                 // Then write the class index
2249                                 writeU2(classIndex);
2250                                 // The write the nameAndType index
2251                                 writeU2(nameAndTypeIndex);
2252                         }
2253                         break;
2254                 case T_float :
2255                         if ((index = wellKnownMethods[APPEND_FLOAT_METHOD]) == 0) {
2256                                 classIndex = literalIndexForJavaLangStringBuffer();
2257                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
2258                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2259                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendFloatSignature);
2260                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
2261                                         writeU1(NameAndTypeTag);
2262                                         writeU2(nameIndex);
2263                                         writeU2(typeIndex);
2264                                 }
2265                                 index = wellKnownMethods[APPEND_FLOAT_METHOD] = currentIndex++;
2266                                 if (index > 0xFFFF){
2267                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2268                                 }
2269                                 // Write the method ref constant into the constant pool
2270                                 // First add the tag
2271                                 writeU1(MethodRefTag);
2272                                 // Then write the class index
2273                                 writeU2(classIndex);
2274                                 // The write the nameAndType index
2275                                 writeU2(nameAndTypeIndex);
2276                         }
2277                         break;
2278                 case T_double :
2279                         if ((index = wellKnownMethods[APPEND_DOUBLE_METHOD]) == 0) {
2280                                 classIndex = literalIndexForJavaLangStringBuffer();
2281                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
2282                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2283                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendDoubleSignature);
2284                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
2285                                         writeU1(NameAndTypeTag);
2286                                         writeU2(nameIndex);
2287                                         writeU2(typeIndex);
2288                                 }
2289                                 index = wellKnownMethods[APPEND_DOUBLE_METHOD] = currentIndex++;
2290                                 if (index > 0xFFFF){
2291                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2292                                 }
2293                                 // Write the method ref constant into the constant pool
2294                                 // First add the tag
2295                                 writeU1(MethodRefTag);
2296                                 // Then write the class index
2297                                 writeU2(classIndex);
2298                                 // The write the nameAndType index
2299                                 writeU2(nameAndTypeIndex);
2300                         }
2301                         break;
2302                 case T_char :
2303                         if ((index = wellKnownMethods[APPEND_CHAR_METHOD]) == 0) {
2304                                 classIndex = literalIndexForJavaLangStringBuffer();
2305                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
2306                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2307                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendCharSignature);
2308                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
2309                                         writeU1(NameAndTypeTag);
2310                                         writeU2(nameIndex);
2311                                         writeU2(typeIndex);
2312                                 }
2313                                 index = wellKnownMethods[APPEND_CHAR_METHOD] = currentIndex++;
2314                                 if (index > 0xFFFF){
2315                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2316                                 }
2317                                 // Write the method ref constant into the constant pool
2318                                 // First add the tag
2319                                 writeU1(MethodRefTag);
2320                                 // Then write the class index
2321                                 writeU2(classIndex);
2322                                 // The write the nameAndType index
2323                                 writeU2(nameAndTypeIndex);
2324                         }
2325                         break;
2326                 case T_boolean :
2327                         if ((index = wellKnownMethods[APPEND_BOOLEAN_METHOD]) == 0) {
2328                                 classIndex = literalIndexForJavaLangStringBuffer();
2329                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
2330                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2331                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendBooleanSignature);
2332                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
2333                                         writeU1(NameAndTypeTag);
2334                                         writeU2(nameIndex);
2335                                         writeU2(typeIndex);
2336                                 }
2337                                 index = wellKnownMethods[APPEND_BOOLEAN_METHOD] = currentIndex++;
2338                                 if (index > 0xFFFF){
2339                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2340                                 }
2341                                 // Write the method ref constant into the constant pool
2342                                 // First add the tag
2343                                 writeU1(MethodRefTag);
2344                                 // Then write the class index
2345                                 writeU2(classIndex);
2346                                 // The write the nameAndType index
2347                                 writeU2(nameAndTypeIndex);
2348                         }
2349                         break;
2350                 case T_Object :
2351                         if ((index = wellKnownMethods[APPEND_OBJECT_METHOD]) == 0) {
2352                                 classIndex = literalIndexForJavaLangStringBuffer();
2353                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
2354                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2355                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendObjectSignature);
2356                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
2357                                         writeU1(NameAndTypeTag);
2358                                         writeU2(nameIndex);
2359                                         writeU2(typeIndex);
2360                                 }
2361                                 index = wellKnownMethods[APPEND_OBJECT_METHOD] = currentIndex++;
2362                                 if (index > 0xFFFF){
2363                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2364                                 }
2365                                 // Write the method ref constant into the constant pool
2366                                 // First add the tag
2367                                 writeU1(MethodRefTag);
2368                                 // Then write the class index
2369                                 writeU2(classIndex);
2370                                 // The write the nameAndType index
2371                                 writeU2(nameAndTypeIndex);
2372                         }
2373                         break;
2374                 case T_String :
2375                 case T_null :
2376                         if ((index = wellKnownMethods[APPEND_STRING_METHOD]) == 0) {
2377                                 classIndex = literalIndexForJavaLangStringBuffer();
2378                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2379                                         int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2380                                         int typeIndex = literalIndex(QualifiedNamesConstants.AppendStringSignature);
2381                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2382                                         writeU1(NameAndTypeTag);
2383                                         writeU2(nameIndex);
2384                                         writeU2(typeIndex);
2385                                 }
2386                                 index = wellKnownMethods[APPEND_STRING_METHOD] = currentIndex++;
2387                                 if (index > 0xFFFF){
2388                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2389                                 }
2390                                 // Write the method ref constant into the constant pool
2391                                 // First add the tag
2392                                 writeU1(MethodRefTag);
2393                                 // Then write the class index
2394                                 writeU2(classIndex);
2395                                 // The write the nameAndType index
2396                                 writeU2(nameAndTypeIndex);
2397                         }
2398                         break;
2399         }
2400         return index;
2401 }
2402 /**
2403  * This method returns the index into the constantPool corresponding to the 
2404  * method descriptor. It can be either an interface method reference constant
2405  * or a method reference constant.
2406  *
2407  * @return <CODE>int</CODE>
2408  */
2409 public int literalIndexForJavaLangStringBufferConstructor() {
2410         int index;
2411         int nameAndTypeIndex;
2412         int classIndex;
2413         // Looking into the method ref table
2414         if ((index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD]) == 0) {
2415                 classIndex = literalIndexForJavaLangStringBuffer();
2416                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2417                                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2418                                         int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
2419                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2420                                         writeU1(NameAndTypeTag);
2421                                         writeU2(nameIndex);
2422                                         writeU2(typeIndex);
2423                                 }
2424                 index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD] = currentIndex++;
2425                 if (index > 0xFFFF){
2426                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2427                 }
2428                 // Write the method ref constant into the constant pool
2429                 // First add the tag
2430                 writeU1(MethodRefTag);
2431                 // Then write the class index
2432                 writeU2(classIndex);
2433                 // The write the nameAndType index
2434                 writeU2(nameAndTypeIndex);
2435         }
2436         return index;
2437 }
2438 /**
2439  * This method returns the index into the constantPool corresponding to the 
2440  * method descriptor. It can be either an interface method reference constant
2441  * or a method reference constant.
2442  *
2443  * @return <CODE>int</CODE>
2444  */
2445 public int literalIndexForJavaLangStringBufferDefaultConstructor() {
2446         int index;
2447         int nameAndTypeIndex;
2448         int classIndex;
2449         // Looking into the method ref table
2450         if ((index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD]) == 0) {
2451                 classIndex = literalIndexForJavaLangStringBuffer();
2452                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
2453                         int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2454                         int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
2455                         nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
2456                         writeU1(NameAndTypeTag);
2457                         writeU2(nameIndex);
2458                         writeU2(typeIndex);
2459                 }
2460                 index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD] = currentIndex++;
2461                 if (index > 0xFFFF){
2462                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2463                 }
2464                 // Write the method ref constant into the constant pool
2465                 // First add the tag
2466                 writeU1(MethodRefTag);
2467                 // Then write the class index
2468                 writeU2(classIndex);
2469                 // The write the nameAndType index
2470                 writeU2(nameAndTypeIndex);
2471         }
2472         return index;
2473 }
2474 /**
2475  * This method returns the index into the constantPool corresponding to the 
2476  * method descriptor. It can be either an interface method reference constant
2477  * or a method reference constant.
2478  *
2479  * @return <CODE>int</CODE>
2480  */
2481 public int literalIndexForJavaLangStringBufferToString() {
2482         int index;
2483         int nameAndTypeIndex;
2484         int classIndex;
2485         // Looking into the method ref table
2486         if ((index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD]) == 0) {
2487                 classIndex = literalIndexForJavaLangStringBuffer();
2488                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE]) == 0) {
2489                         int nameIndex = literalIndex(QualifiedNamesConstants.ToString);
2490                         int typeIndex = literalIndex(QualifiedNamesConstants.ToStringSignature);
2491                         nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2492                         writeU1(NameAndTypeTag);
2493                         writeU2(nameIndex);
2494                         writeU2(typeIndex);
2495                 }
2496                 index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD] = currentIndex++;
2497                 if (index > 0xFFFF){
2498                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2499                 }
2500                 // Write the method ref constant into the constant pool
2501                 // First add the tag
2502                 writeU1(MethodRefTag);
2503                 // Then write the class index
2504                 writeU2(classIndex);
2505                 // The write the nameAndType index
2506                 writeU2(nameAndTypeIndex);
2507         }
2508         return index;
2509 }
2510 /**
2511  * This method returns the index into the constantPool corresponding to the 
2512  * method descriptor. It can be either an interface method reference constant
2513  * or a method reference constant.
2514  *
2515  * @return <CODE>int</CODE>
2516  */
2517 public int literalIndexForJavaLangStringIntern() {
2518         int index;
2519         int nameAndTypeIndex;
2520         int classIndex;
2521         // Looking into the method ref table
2522         if ((index = wellKnownMethods[STRING_INTERN_METHOD]) == 0) {
2523                 classIndex = literalIndexForJavaLangString();
2524                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE]) == 0) {
2525                         int nameIndex = literalIndex(QualifiedNamesConstants.Intern);
2526                         int typeIndex = literalIndex(QualifiedNamesConstants.InternSignature);
2527                         nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE] = currentIndex++;
2528                         writeU1(NameAndTypeTag);
2529                         writeU2(nameIndex);
2530                         writeU2(typeIndex);
2531                 }
2532                 index = wellKnownMethods[STRING_INTERN_METHOD] = currentIndex++;
2533                 if (index > 0xFFFF){
2534                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2535                 }
2536                 // Write the method ref constant into the constant pool
2537                 // First add the tag
2538                 writeU1(MethodRefTag);
2539                 // Then write the class index
2540                 writeU2(classIndex);
2541                 // The write the nameAndType index
2542                 writeU2(nameAndTypeIndex);
2543         }
2544         return index;
2545 }
2546 /**
2547  * This method returns the index into the constantPool corresponding to the 
2548  * method descriptor. It can be either an interface method reference constant
2549  * or a method reference constant.
2550  *
2551  * @return <CODE>int</CODE>
2552  */
2553 public int literalIndexForJavaLangStringValueOf(int typeID) {
2554         int index = 0;
2555         int nameAndTypeIndex = 0;
2556         int classIndex = literalIndexForJavaLangString();
2557         switch (typeID) {
2558                 case T_int :
2559                 case T_byte :
2560                 case T_short :
2561                         if ((index = wellKnownMethods[VALUEOF_INT_METHOD]) == 0) {
2562                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE]) == 0) {
2563                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2564                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfIntSignature);
2565                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
2566                                         writeU1(NameAndTypeTag);
2567                                         writeU2(nameIndex);
2568                                         writeU2(typeIndex);
2569                                 }
2570                                 index = wellKnownMethods[VALUEOF_INT_METHOD] = currentIndex++;
2571                                 if (index > 0xFFFF){
2572                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2573                                 }
2574                                 // Write the method ref constant into the constant pool
2575                                 // First add the tag
2576                                 writeU1(MethodRefTag);
2577                                 // Then write the class index
2578                                 writeU2(classIndex);
2579                                 // The write the nameAndType index
2580                                 writeU2(nameAndTypeIndex);
2581                         }
2582                         break;
2583                 case T_long :
2584                         if ((index = wellKnownMethods[VALUEOF_LONG_METHOD]) == 0) {
2585                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE]) == 0) {
2586                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2587                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfLongSignature);
2588                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
2589                                         writeU1(NameAndTypeTag);
2590                                         writeU2(nameIndex);
2591                                         writeU2(typeIndex);
2592                                 }
2593                                 index = wellKnownMethods[VALUEOF_LONG_METHOD] = currentIndex++;
2594                                 if (index > 0xFFFF){
2595                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2596                                 }
2597                                 // Write the method ref constant into the constant pool
2598                                 // First add the tag
2599                                 writeU1(MethodRefTag);
2600                                 // Then write the class index
2601                                 writeU2(classIndex);
2602                                 // The write the nameAndType index
2603                                 writeU2(nameAndTypeIndex);
2604                         }
2605                         break;
2606                 case T_float :
2607                         if ((index = wellKnownMethods[VALUEOF_FLOAT_METHOD]) == 0) {
2608                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
2609                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2610                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfFloatSignature);
2611                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
2612                                         writeU1(NameAndTypeTag);
2613                                         writeU2(nameIndex);
2614                                         writeU2(typeIndex);
2615                                 }
2616                                 index = wellKnownMethods[VALUEOF_FLOAT_METHOD] = currentIndex++;
2617                                 if (index > 0xFFFF){
2618                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2619                                 }
2620                                 // Write the method ref constant into the constant pool
2621                                 // First add the tag
2622                                 writeU1(MethodRefTag);
2623                                 // Then write the class index
2624                                 writeU2(classIndex);
2625                                 // The write the nameAndType index
2626                                 writeU2(nameAndTypeIndex);
2627                         }
2628                         break;
2629                 case T_double :
2630                         if ((index = wellKnownMethods[VALUEOF_DOUBLE_METHOD]) == 0) {
2631                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
2632                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2633                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfDoubleSignature);
2634                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
2635                                         writeU1(NameAndTypeTag);
2636                                         writeU2(nameIndex);
2637                                         writeU2(typeIndex);
2638                                 }
2639                                 index = wellKnownMethods[VALUEOF_DOUBLE_METHOD] = currentIndex++;
2640                                 if (index > 0xFFFF){
2641                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2642                                 }
2643                                 // Write the method ref constant into the constant pool
2644                                 // First add the tag
2645                                 writeU1(MethodRefTag);
2646                                 // Then write the class index
2647                                 writeU2(classIndex);
2648                                 // The write the nameAndType index
2649                                 writeU2(nameAndTypeIndex);
2650                         }
2651                         break;
2652                 case T_char :
2653                         if ((index = wellKnownMethods[VALUEOF_CHAR_METHOD]) == 0) {
2654                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
2655                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2656                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfCharSignature);
2657                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
2658                                         writeU1(NameAndTypeTag);
2659                                         writeU2(nameIndex);
2660                                         writeU2(typeIndex);
2661                                 }
2662                                 index = wellKnownMethods[VALUEOF_CHAR_METHOD] = currentIndex++;
2663                                 if (index > 0xFFFF){
2664                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2665                                 }
2666                                 // Write the method ref constant into the constant pool
2667                                 // First add the tag
2668                                 writeU1(MethodRefTag);
2669                                 // Then write the class index
2670                                 writeU2(classIndex);
2671                                 // The write the nameAndType index
2672                                 writeU2(nameAndTypeIndex);
2673                         }
2674                         break;
2675                 case T_boolean :
2676                         if ((index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD]) == 0) {
2677                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
2678                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2679                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfBooleanSignature);
2680                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
2681                                         writeU1(NameAndTypeTag);
2682                                         writeU2(nameIndex);
2683                                         writeU2(typeIndex);
2684                                 }
2685                                 index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD] = currentIndex++;
2686                                 if (index > 0xFFFF){
2687                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2688                                 }
2689                                 // Write the method ref constant into the constant pool
2690                                 // First add the tag
2691                                 writeU1(MethodRefTag);
2692                                 // Then write the class index
2693                                 writeU2(classIndex);
2694                                 // The write the nameAndType index
2695                                 writeU2(nameAndTypeIndex);
2696                         }
2697                         break;
2698                 case T_Object :
2699                         if ((index = wellKnownMethods[VALUEOF_OBJECT_METHOD]) == 0) {
2700                                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
2701                                         int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2702                                         int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfObjectSignature);
2703                                         nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
2704                                         writeU1(NameAndTypeTag);
2705                                         writeU2(nameIndex);
2706                                         writeU2(typeIndex);
2707                                 }
2708                                 index = wellKnownMethods[VALUEOF_OBJECT_METHOD] = currentIndex++;
2709                                 if (index > 0xFFFF){
2710                                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2711                                 }
2712                                 // Write the method ref constant into the constant pool
2713                                 // First add the tag
2714                                 writeU1(MethodRefTag);
2715                                 // Then write the class index
2716                                 writeU2(classIndex);
2717                                 // The write the nameAndType index
2718                                 writeU2(nameAndTypeIndex);
2719                         }
2720                         break;
2721         }
2722         return index;
2723 }
2724 /**
2725  * This method returns the index into the constantPool corresponding to the type descriptor.
2726  *
2727  * @param TypeBinding aTypeBinding
2728  * @return <CODE>int</CODE>
2729  */
2730 public int literalIndexForJavaLangSystem() {
2731         int index;
2732         if ((index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE]) == 0) {
2733                 int nameIndex;
2734                 // The entry doesn't exit yet
2735                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangSystemConstantPoolName);
2736                 index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE] = currentIndex++;
2737                 if (index > 0xFFFF){
2738                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2739                 }
2740                 writeU1(ClassTag);
2741                 // Then add the 8 bytes representing the long
2742                 writeU2(nameIndex);
2743         }
2744         return index;
2745 }
2746 /**
2747  * This method returns the index into the constantPool corresponding to the 
2748  * method descriptor. It can be either an interface method reference constant
2749  * or a method reference constant.
2750  *
2751  * @return <CODE>int</CODE>
2752  */
2753 public int literalIndexForJavaLangSystemExitInt() {
2754         int index;
2755         int nameAndTypeIndex;
2756         int classIndex;
2757         // Looking into the method ref table
2758         if ((index = wellKnownMethods[SYSTEM_EXIT_METHOD]) == 0) {
2759                 classIndex = literalIndexForJavaLangSystem();
2760                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE]) == 0) {
2761                         int nameIndex = literalIndex(QualifiedNamesConstants.Exit);
2762                         int typeIndex = literalIndex(QualifiedNamesConstants.ExitIntSignature);
2763                         nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE] = currentIndex++;
2764                         writeU1(NameAndTypeTag);
2765                         writeU2(nameIndex);
2766                         writeU2(typeIndex);
2767                 }
2768                 index = wellKnownMethods[SYSTEM_EXIT_METHOD] = currentIndex++;
2769                 if (index > 0xFFFF){
2770                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2771                 }
2772                 // Write the method ref constant into the constant pool
2773                 // First add the tag
2774                 writeU1(MethodRefTag);
2775                 // Then write the class index
2776                 writeU2(classIndex);
2777                 // The write the nameAndType index
2778                 writeU2(nameAndTypeIndex);
2779         }
2780         return index;
2781 }
2782 /**
2783  * This method returns the index into the constantPool 
2784  * corresponding to the field binding aFieldBinding.
2785  *
2786  * @return <CODE>int</CODE>
2787  */
2788 public int literalIndexForJavaLangSystemOut() {
2789         int index;
2790         if ((index = wellKnownFields[OUT_SYSTEM_FIELD]) == 0) {
2791                 int nameAndTypeIndex;
2792                 int classIndex;
2793                 // The entry doesn't exit yet
2794                 classIndex = literalIndexForJavaLangSystem();
2795                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE]) == 0) {
2796                         int nameIndex = literalIndex(QualifiedNamesConstants.Out);
2797                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaIoPrintStreamSignature);
2798                         nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE] = currentIndex++;
2799                         writeU1(NameAndTypeTag);
2800                         writeU2(nameIndex);
2801                         writeU2(typeIndex);
2802                 }
2803                 index = wellKnownFields[OUT_SYSTEM_FIELD] = currentIndex++;
2804                 if (index > 0xFFFF){
2805                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2806                 }
2807                 writeU1(FieldRefTag);
2808                 writeU2(classIndex);
2809                 writeU2(nameAndTypeIndex);
2810         }
2811         return index;
2812 }
2813 /**
2814  * This method returns the index into the constantPool corresponding to the type descriptor.
2815  *
2816  * @param TypeBinding aTypeBinding
2817  * @return <CODE>int</CODE>
2818  */
2819 public int literalIndexForJavaLangThrowable() {
2820         int index;
2821         if ((index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE]) == 0) {
2822                 int nameIndex;
2823                 // The entry doesn't exit yet
2824                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangThrowableConstantPoolName);
2825                 index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE] = currentIndex++;
2826                 if (index > 0xFFFF){
2827                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2828                 }
2829                 writeU1(ClassTag);
2830                 // Then add the 8 bytes representing the long
2831                 writeU2(nameIndex);
2832         }
2833         return index;
2834 }
2835 /**
2836  * This method returns the index into the constantPool corresponding to the 
2837  * method descriptor. It can be either an interface method reference constant
2838  * or a method reference constant.
2839  *
2840  * @return <CODE>int</CODE>
2841  */
2842 public int literalIndexForJavaLangThrowableGetMessage() {
2843         int index;
2844         int nameAndTypeIndex;
2845         int classIndex;
2846         // Looking into the method ref table
2847         if ((index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD]) == 0) {
2848                 classIndex = literalIndexForJavaLangThrowable();
2849                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE]) == 0) {
2850                         int nameIndex = literalIndex(QualifiedNamesConstants.GetMessage);
2851                         int typeIndex = literalIndex(QualifiedNamesConstants.GetMessageSignature);
2852                         nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE] = currentIndex++;
2853                         writeU1(NameAndTypeTag);
2854                         writeU2(nameIndex);
2855                         writeU2(typeIndex);
2856                 }
2857                 index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD] = currentIndex++;
2858                 if (index > 0xFFFF){
2859                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2860                 }
2861                 // Write the method ref constant into the constant pool
2862                 // First add the tag
2863                 writeU1(MethodRefTag);
2864                 // Then write the class index
2865                 writeU2(classIndex);
2866                 // The write the nameAndType index
2867                 writeU2(nameAndTypeIndex);
2868         }
2869         return index;
2870 }
2871 /**
2872  * This method returns the index into the constantPool corresponding to the type descriptor.
2873  *
2874  * @param TypeBinding aTypeBinding
2875  * @return <CODE>int</CODE>
2876  */
2877 public int literalIndexForJavaLangVoid() {
2878         int index;
2879         if ((index = wellKnownTypes[JAVA_LANG_VOID_TYPE]) == 0) {
2880                 int nameIndex;
2881                 // The entry doesn't exit yet
2882                 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangVoidConstantPoolName);
2883                 index = wellKnownTypes[JAVA_LANG_VOID_TYPE] = currentIndex++;
2884                 if (index > 0xFFFF){
2885                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2886                 }
2887                 writeU1(ClassTag);
2888                 // Then add the 8 bytes representing the long
2889                 writeU2(nameIndex);
2890         }
2891         return index;
2892 }
2893 /**
2894  * This method returns the index into the constantPool 
2895  * corresponding to the field binding aFieldBinding.
2896  *
2897  * @return <CODE>int</CODE>
2898  */
2899 public int literalIndexForJavaLangVoidTYPE() {
2900         int index;
2901         if ((index = wellKnownFields[TYPE_VOID_FIELD]) == 0) {
2902                 int nameAndTypeIndex;
2903                 int classIndex;
2904                 // The entry doesn't exit yet
2905                 classIndex = literalIndexForJavaLangVoid();
2906                 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
2907                         int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
2908                         int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
2909                         nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
2910                         writeU1(NameAndTypeTag);
2911                         writeU2(nameIndex);
2912                         writeU2(typeIndex);
2913                 }
2914                 index = wellKnownFields[TYPE_VOID_FIELD] = currentIndex++;
2915                 if (index > 0xFFFF){
2916                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2917                 }
2918                 writeU1(FieldRefTag);
2919                 writeU2(classIndex);
2920                 writeU2(nameAndTypeIndex);
2921         }
2922         return index;
2923 }
2924 /**
2925  * This method returns the index into the constantPool corresponding to the type descriptor.
2926  *
2927  * @param char[] stringName
2928  * @return <CODE>int</CODE>
2929  */
2930 public int literalIndexForLdc(char[] stringCharArray) {
2931         int index;
2932         if ((index = stringCache.get(stringCharArray)) < 0) {
2933                 int stringIndex;
2934                 // The entry doesn't exit yet
2935                 if ((stringIndex = UTF8Cache.get(stringCharArray)) < 0) {
2936                         // The entry doesn't exit yet
2937                         // Write the tag first
2938                         writeU1(Utf8Tag);
2939                         // Then the size of the stringName array
2940                         int savedCurrentOffset = currentOffset;
2941                         if (currentOffset + 2 >= poolContent.length) {
2942                                 // we need to resize the poolContent array because we won't have
2943                                 // enough space to write the length
2944                                 int length = poolContent.length;
2945                                 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
2946                         }
2947                         currentOffset += 2;
2948                         int length = 0;
2949                         for (int i = 0; i < stringCharArray.length; i++) {
2950                                 char current = stringCharArray[i];
2951                                 if ((current >= 0x0001) && (current <= 0x007F)) {
2952                                         // we only need one byte: ASCII table
2953                                         writeU1(current);
2954                                         length++;
2955                                 } else
2956                                         if (current > 0x07FF) {
2957                                                 // we need 3 bytes
2958                                                 length += 3;
2959                                                 writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
2960                                                 writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
2961                                                 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
2962                                         } else {
2963                                                 // we can be 0 or between 0x0080 and 0x07FF
2964                                                 // In that case we only need 2 bytes
2965                                                 length += 2;
2966                                                 writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
2967                                                 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
2968                                         }
2969                         }
2970                         if (length >= 65535) {
2971                                 currentOffset = savedCurrentOffset - 1;
2972                                 return -1;
2973                         }
2974                         stringIndex = UTF8Cache.put(stringCharArray, currentIndex++);
2975                         // Now we know the length that we have to write in the constant pool
2976                         // we use savedCurrentOffset to do that
2977                         if (length > 65535) {
2978                                 return 0;
2979                         }
2980                         poolContent[savedCurrentOffset] = (byte) (length >> 8);
2981                         poolContent[savedCurrentOffset + 1] = (byte) length;
2982                 }
2983                 index = stringCache.put(stringCharArray, currentIndex++);
2984                 if (index > 0xFFFF){
2985                         this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2986                 }
2987                 // Write the tag first
2988                 writeU1(StringTag);
2989                 // Then the string index
2990                 writeU2(stringIndex);
2991         }
2992         return index;
2993 }
2994 /**
2995  * This method returns the index into the constantPool corresponding 
2996  * nameAndType constant with nameIndex, typeIndex.
2997  *
2998  * @param int nameIndex
2999  * @param int nameIndex
3000  * @param org.eclipse.jdt.internal.compiler.lookup.MethodBinding a methodBinding
3001  * @return <CODE>int</CODE>
3002  */
3003 public int literalIndexForMethods(int nameIndex, int typeIndex, MethodBinding key) {
3004         int index;
3005         int indexOfWellKnownMethodNameAndType;
3006         if ((indexOfWellKnownMethodNameAndType = indexOfWellKnownMethodNameAndType(key)) == -1) {
3007                 // check if the entry exists
3008                 if ((index = nameAndTypeCacheForMethods.get(key)) == -1) {
3009                         // The entry doesn't exit yet
3010                         index = nameAndTypeCacheForMethods.put(key, currentIndex++);
3011                         if (index > 0xFFFF){
3012                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
3013                         }
3014                         writeU1(NameAndTypeTag);
3015                         writeU2(nameIndex);
3016                         writeU2(typeIndex);
3017                 }
3018         } else {
3019                 if ((index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType]) == 0) {
3020                         index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType] = currentIndex++;
3021                         if (index > 0xFFFF){
3022                                 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
3023                         }
3024                         writeU1(NameAndTypeTag);
3025                         writeU2(nameIndex);
3026                         writeU2(typeIndex);
3027                 }
3028         }
3029         return index;
3030 }
3031 /**
3032  * This method returns the index into the constantPool corresponding to the 
3033  * method descriptor. It can be either an interface method reference constant
3034  * or a method reference constant.
3035  *
3036  * @return <CODE>int</CODE>
3037  */
3038 public int literalIndexForJavaLangObjectGetClass() {
3039         int index;
3040         int nameAndTypeIndex;
3041         int classIndex;
3042         // Looking into the method ref table
3043         if ((index = wellKnownMethods[GETCLASS_OBJECT_METHOD]) == 0) {
3044                 classIndex = literalIndexForJavaLangObject();
3045                 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
3046                         int nameIndex = literalIndex(QualifiedNamesConstants.GetClass);
3047                         int typeIndex = literalIndex(QualifiedNamesConstants.GetClassSignature);
3048                         nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
3049                         writeU1(NameAndTypeTag);
3050                         writeU2(nameIndex);
3051                         writeU2(typeIndex);
3052                 }
3053                 index = wellKnownMethods[GETCLASS_OBJECT_METHOD] = currentIndex++;
3054                 // Write the method ref constant into the constant pool
3055                 // First add the tag
3056                 writeU1(MethodRefTag);
3057                 // Then write the class index
3058                 writeU2(classIndex);
3059                 // The write the nameAndType index
3060                 writeU2(nameAndTypeIndex);
3061         }
3062         return index;
3063 }
3064 /**
3065  * This method is used to clean the receiver in case of a clinit header is generated, but the 
3066  * clinit has no code.
3067  * This implementation assumes that the clinit is the first method to be generated.
3068  * @see org.eclipse.jdt.internal.compiler.ast.TypeDeclaration#addClinit()
3069  */
3070 public void resetForClinit(int constantPoolIndex, int constantPoolOffset) {
3071         currentIndex = constantPoolIndex;
3072         currentOffset = constantPoolOffset;
3073         if (UTF8Cache.get(AttributeNamesConstants.CodeName) >= constantPoolIndex) {
3074                 UTF8Cache.remove(AttributeNamesConstants.CodeName);
3075         }
3076         if (UTF8Cache.get(QualifiedNamesConstants.ClinitSignature) >= constantPoolIndex) {
3077                 UTF8Cache.remove(QualifiedNamesConstants.ClinitSignature);
3078         }
3079         if (UTF8Cache.get(QualifiedNamesConstants.Clinit) >= constantPoolIndex) {
3080                 UTF8Cache.remove(QualifiedNamesConstants.Clinit);
3081         }
3082 }
3083 /**
3084  * Write a unsigned byte into the byte array
3085  * 
3086  * @param <CODE>int</CODE> The value to write into the byte array
3087  */
3088 protected final void writeU1(int value) {
3089         try {
3090                 poolContent[currentOffset++] = (byte) value;
3091         } catch (IndexOutOfBoundsException e) {
3092                 //currentOffset has been ++ already (see the -1)
3093                 int length = poolContent.length;
3094                 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
3095                 poolContent[currentOffset - 1] = (byte) value;
3096         }
3097 }
3098 /**
3099  * Write a unsigned byte into the byte array
3100  * 
3101  * @param <CODE>int</CODE> The value to write into the byte array
3102  */
3103 protected final void writeU2(int value) {
3104         //first byte
3105         try {
3106                 poolContent[currentOffset++] = (byte) (value >> 8);
3107         } catch (IndexOutOfBoundsException e) {
3108                  //currentOffset has been ++ already (see the -1)
3109                 int length = poolContent.length;
3110                 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
3111                 poolContent[currentOffset - 1] = (byte) (value >> 8);
3112         }
3113         try {
3114                 poolContent[currentOffset++] = (byte) value;
3115         } catch (IndexOutOfBoundsException e) {
3116                  //currentOffset has been ++ already (see the -1)
3117                 int length = poolContent.length;
3118                 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
3119                 poolContent[currentOffset - 1] = (byte) value;
3120         }
3121 }
3122 }