1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.codegen;
13 import org.eclipse.jdt.core.compiler.*;
14 import org.eclipse.jdt.internal.compiler.ClassFile;
16 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17 import org.eclipse.jdt.internal.compiler.lookup.*;
20 * This type is used to store all the constant pool entries.
22 public class ConstantPool implements ClassFileConstants, TypeIds {
23 public static final int DOUBLE_INITIAL_SIZE = 5;
24 public static final int FLOAT_INITIAL_SIZE = 3;
25 public static final int INT_INITIAL_SIZE = 248;
26 public static final int LONG_INITIAL_SIZE = 5;
27 public static final int UTF8_INITIAL_SIZE = 778;
28 public static final int STRING_INITIAL_SIZE = 761;
29 public static final int FIELD_INITIAL_SIZE = 156;
30 public static final int METHOD_INITIAL_SIZE = 236;
31 public static final int INTERFACE_INITIAL_SIZE = 50;
32 public static final int CLASS_INITIAL_SIZE = 86;
33 public static final int NAMEANDTYPE_INITIAL_SIZE = 272;
34 public static final int CONSTANTPOOL_INITIAL_SIZE = 2000;
35 public static final int CONSTANTPOOL_GROW_SIZE = 6000;
36 protected DoubleCache doubleCache;
37 protected FloatCache floatCache;
38 protected IntegerCache intCache;
39 protected LongCache longCache;
40 public CharArrayCache UTF8Cache;
41 protected CharArrayCache stringCache;
42 protected ObjectCache fieldCache;
43 protected ObjectCache methodCache;
44 protected ObjectCache interfaceMethodCache;
45 protected ObjectCache classCache;
46 protected FieldNameAndTypeCache nameAndTypeCacheForFields;
47 protected MethodNameAndTypeCache nameAndTypeCacheForMethods;
48 int[] wellKnownTypes = new int[21];
49 int[] wellKnownMethods = new int[36];
50 int[] wellKnownFields = new int[10];
51 int[] wellKnownFieldNameAndTypes = new int[2];
52 int[] wellKnownMethodNameAndTypes = new int[33];
53 public byte[] poolContent;
54 public int currentIndex = 1;
55 public int currentOffset;
56 // predefined constant index for well known types
57 final static int JAVA_LANG_BOOLEAN_TYPE = 0;
58 final static int JAVA_LANG_BYTE_TYPE = 1;
59 final static int JAVA_LANG_CHARACTER_TYPE = 2;
60 final static int JAVA_LANG_DOUBLE_TYPE = 3;
61 final static int JAVA_LANG_FLOAT_TYPE = 4;
62 final static int JAVA_LANG_INTEGER_TYPE = 5;
63 final static int JAVA_LANG_LONG_TYPE = 6;
64 final static int JAVA_LANG_SHORT_TYPE = 7;
65 final static int JAVA_LANG_VOID_TYPE = 8;
66 final static int JAVA_LANG_CLASS_TYPE = 9;
67 final static int JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE = 10;
68 final static int JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE = 11;
69 final static int JAVA_LANG_OBJECT_TYPE = 12;
70 final static int JAVA_LANG_STRING_TYPE = 13;
71 final static int JAVA_LANG_STRINGBUFFER_TYPE = 14;
72 final static int JAVA_LANG_SYSTEM_TYPE = 15;
73 final static int JAVA_LANG_THROWABLE_TYPE = 16;
74 final static int JAVA_LANG_ERROR_TYPE = 17;
75 final static int JAVA_LANG_EXCEPTION_TYPE = 18;
76 final static int JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE = 19;
77 final static int JAVA_LANG_ASSERTIONERROR_TYPE = 20;
79 // predefined constant index for well known fields
80 final static int TYPE_BYTE_FIELD = 0;
81 final static int TYPE_SHORT_FIELD = 1;
82 final static int TYPE_CHARACTER_FIELD = 2;
83 final static int TYPE_INTEGER_FIELD = 3;
84 final static int TYPE_LONG_FIELD = 4;
85 final static int TYPE_FLOAT_FIELD = 5;
86 final static int TYPE_DOUBLE_FIELD = 6;
87 final static int TYPE_BOOLEAN_FIELD = 7;
88 final static int TYPE_VOID_FIELD = 8;
89 final static int OUT_SYSTEM_FIELD = 9;
90 // predefined constant index for well known methods
91 final static int FORNAME_CLASS_METHOD = 0;
92 final static int NOCLASSDEFFOUNDERROR_CONSTR_METHOD = 1;
93 final static int APPEND_INT_METHOD = 2;
94 final static int APPEND_FLOAT_METHOD = 3;
95 final static int APPEND_LONG_METHOD = 4;
96 final static int APPEND_OBJECT_METHOD = 5;
97 final static int APPEND_CHAR_METHOD = 6;
98 final static int APPEND_STRING_METHOD = 7;
99 final static int APPEND_BOOLEAN_METHOD = 8;
100 final static int APPEND_DOUBLE_METHOD = 9;
101 final static int STRINGBUFFER_STRING_CONSTR_METHOD = 10;
102 final static int STRINGBUFFER_DEFAULT_CONSTR_METHOD = 11;
103 final static int STRINGBUFFER_TOSTRING_METHOD = 12;
104 final static int SYSTEM_EXIT_METHOD = 13;
105 final static int THROWABLE_GETMESSAGE_METHOD = 14;
106 final static int JAVALANGERROR_CONSTR_METHOD = 15;
107 final static int NEWINSTANCE_CONSTRUCTOR_METHOD = 16;
108 final static int STRING_INTERN_METHOD = 17;
109 final static int VALUEOF_INT_METHOD = 18;
110 final static int VALUEOF_FLOAT_METHOD = 19;
111 final static int VALUEOF_LONG_METHOD = 20;
112 final static int VALUEOF_OBJECT_METHOD = 21;
113 final static int VALUEOF_CHAR_METHOD = 22;
114 final static int VALUEOF_BOOLEAN_METHOD = 23;
115 final static int VALUEOF_DOUBLE_METHOD = 24;
116 final static int ASSERTIONERROR_CONSTR_OBJECT_METHOD = 25;
117 final static int ASSERTIONERROR_CONSTR_INT_METHOD = 26;
118 final static int ASSERTIONERROR_CONSTR_LONG_METHOD = 27;
119 final static int ASSERTIONERROR_CONSTR_FLOAT_METHOD = 28;
120 final static int ASSERTIONERROR_CONSTR_DOUBLE_METHOD = 29;
121 final static int ASSERTIONERROR_CONSTR_BOOLEAN_METHOD = 30;
122 final static int ASSERTIONERROR_CONSTR_CHAR_METHOD = 31;
123 final static int ASSERTIONERROR_DEFAULT_CONSTR_METHOD = 32;
124 final static int DESIREDASSERTIONSTATUS_CLASS_METHOD = 33;
125 final static int GETCLASS_OBJECT_METHOD = 34;
126 final static int GETCOMPONENTTYPE_CLASS_METHOD = 35;
128 // predefined constant index for well known name and type for fields
129 final static int TYPE_JAVALANGCLASS_NAME_AND_TYPE = 0;
130 final static int OUT_SYSTEM_NAME_AND_TYPE = 1;
131 // predefined constant index for well known name and type for methods
132 final static int FORNAME_CLASS_METHOD_NAME_AND_TYPE = 0;
133 final static int CONSTR_STRING_METHOD_NAME_AND_TYPE = 1;
134 final static int DEFAULT_CONSTR_METHOD_NAME_AND_TYPE = 2;
135 final static int APPEND_INT_METHOD_NAME_AND_TYPE = 3;
136 final static int APPEND_FLOAT_METHOD_NAME_AND_TYPE = 4;
137 final static int APPEND_LONG_METHOD_NAME_AND_TYPE = 5;
138 final static int APPEND_OBJECT_METHOD_NAME_AND_TYPE = 6;
139 final static int APPEND_CHAR_METHOD_NAME_AND_TYPE = 7;
140 final static int APPEND_STRING_METHOD_NAME_AND_TYPE = 8;
141 final static int APPEND_BOOLEAN_METHOD_NAME_AND_TYPE = 9;
142 final static int APPEND_DOUBLE_METHOD_NAME_AND_TYPE = 10;
143 final static int TOSTRING_METHOD_NAME_AND_TYPE = 11;
144 final static int EXIT_METHOD_NAME_AND_TYPE = 12;
145 final static int GETMESSAGE_METHOD_NAME_AND_TYPE = 13;
146 final static int NEWINSTANCE_METHOD_NAME_AND_TYPE = 14;
147 final static int INTERN_METHOD_NAME_AND_TYPE = 15;
148 final static int VALUEOF_INT_METHOD_NAME_AND_TYPE = 16;
149 final static int VALUEOF_FLOAT_METHOD_NAME_AND_TYPE = 17;
150 final static int VALUEOF_LONG_METHOD_NAME_AND_TYPE = 18;
151 final static int VALUEOF_OBJECT_METHOD_NAME_AND_TYPE = 19;
152 final static int VALUEOF_CHAR_METHOD_NAME_AND_TYPE = 20;
153 final static int VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE = 21;
154 final static int VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE = 22;
155 final static int CONSTR_INT_METHOD_NAME_AND_TYPE = 23;
156 final static int CONSTR_LONG_METHOD_NAME_AND_TYPE = 24;
157 final static int CONSTR_FLOAT_METHOD_NAME_AND_TYPE = 25;
158 final static int CONSTR_DOUBLE_METHOD_NAME_AND_TYPE = 26;
159 final static int CONSTR_OBJECT_METHOD_NAME_AND_TYPE = 27;
160 final static int CONSTR_CHAR_METHOD_NAME_AND_TYPE = 28;
161 final static int CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE = 29;
162 final static int DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE = 30;
163 final static int GETCLASS_OBJECT_METHOD_NAME_AND_TYPE = 31;
164 final static int GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE = 32;
166 public ClassFile classFile;
169 * ConstantPool constructor comment.
171 public ConstantPool(ClassFile classFile) {
172 this.UTF8Cache = new CharArrayCache(UTF8_INITIAL_SIZE);
173 this.stringCache = new CharArrayCache(STRING_INITIAL_SIZE);
174 this.fieldCache = new ObjectCache(FIELD_INITIAL_SIZE);
175 this.methodCache = new ObjectCache(METHOD_INITIAL_SIZE);
176 this.interfaceMethodCache = new ObjectCache(INTERFACE_INITIAL_SIZE);
177 this.classCache = new ObjectCache(CLASS_INITIAL_SIZE);
178 this.nameAndTypeCacheForMethods = new MethodNameAndTypeCache(NAMEANDTYPE_INITIAL_SIZE);
179 this.nameAndTypeCacheForFields = new FieldNameAndTypeCache(NAMEANDTYPE_INITIAL_SIZE);
180 this.poolContent = classFile.header;
181 this.currentOffset = classFile.headerOffset;
182 // currentOffset is initialized to 0 by default
183 this.currentIndex = 1;
184 this.classFile = classFile;
187 * Return the content of the receiver
189 public byte[] dumpBytes() {
190 System.arraycopy(poolContent, 0, (poolContent = new byte[currentOffset]), 0, currentOffset);
194 * Return the index of the @fieldBinding.
196 * Returns -1 if the @fieldBinding is not a predefined fieldBinding,
197 * the right index otherwise.
199 * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
200 * @return <CODE>int</CODE>
202 public int indexOfWellKnownFieldNameAndType(FieldBinding fieldBinding) {
203 if ((fieldBinding.type.id == T_JavaLangClass) && (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE)))
204 return TYPE_JAVALANGCLASS_NAME_AND_TYPE;
205 if ((fieldBinding.type.id == T_JavaIoPrintStream) && (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.Out)))
206 return OUT_SYSTEM_NAME_AND_TYPE;
210 * Return the index of the @fieldBinding.
212 * Returns -1 if the @fieldBinding is not a predefined fieldBinding,
213 * the right index otherwise.
215 * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
216 * @return <CODE>int</CODE>
218 public int indexOfWellKnownFields(FieldBinding fieldBinding) {
219 switch (fieldBinding.declaringClass.id) {
220 case T_JavaLangByte :
221 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
222 return TYPE_BYTE_FIELD;
224 case T_JavaLangShort :
225 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
226 return TYPE_SHORT_FIELD;
228 case T_JavaLangCharacter :
229 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
230 return TYPE_CHARACTER_FIELD;
232 case T_JavaLangInteger :
233 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
234 return TYPE_INTEGER_FIELD;
236 case T_JavaLangLong :
237 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
238 return TYPE_LONG_FIELD;
240 case T_JavaLangFloat :
241 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
242 return TYPE_FLOAT_FIELD;
244 case T_JavaLangDouble :
245 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
246 return TYPE_DOUBLE_FIELD;
248 case T_JavaLangBoolean :
249 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
250 return TYPE_BOOLEAN_FIELD;
252 case T_JavaLangVoid :
253 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
254 return TYPE_VOID_FIELD;
256 case T_JavaLangSystem :
257 if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.Out))
258 return OUT_SYSTEM_FIELD;
263 * Return the index of the @methodBinding.
265 * Returns -1 if the @methodBinding is not a predefined methodBinding,
266 * the right index otherwise.
268 * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
269 * @return <CODE>int</CODE>
271 public int indexOfWellKnownMethodNameAndType(MethodBinding methodBinding) {
272 char firstChar = methodBinding.selector[0];
275 if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (methodBinding.returnType.id == T_JavaLangClass) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ForName))) {
276 // This method binding is forName(java.lang.String)
277 return FORNAME_CLASS_METHOD_NAME_AND_TYPE;
281 if (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
282 switch(methodBinding.parameters.length) {
284 switch(methodBinding.parameters[0].id) {
286 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.StringConstructorSignature)) {
287 return CONSTR_STRING_METHOD_NAME_AND_TYPE;
292 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorObjectConstrSignature)) {
293 return CONSTR_OBJECT_METHOD_NAME_AND_TYPE;
298 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorIntConstrSignature)) {
299 return CONSTR_INT_METHOD_NAME_AND_TYPE;
304 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorCharConstrSignature)) {
305 return CONSTR_CHAR_METHOD_NAME_AND_TYPE;
310 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorBooleanConstrSignature)) {
311 return CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE;
316 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorFloatConstrSignature)) {
317 return CONSTR_FLOAT_METHOD_NAME_AND_TYPE;
322 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorDoubleConstrSignature)) {
323 return CONSTR_DOUBLE_METHOD_NAME_AND_TYPE;
328 if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorLongConstrSignature)) {
329 return CONSTR_LONG_METHOD_NAME_AND_TYPE;
335 if (methodBinding.signature().length == 3) {
336 return DEFAULT_CONSTR_METHOD_NAME_AND_TYPE;
342 if ((methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
343 switch (methodBinding.parameters[0].id) {
347 // This method binding is append(int)
348 return APPEND_INT_METHOD_NAME_AND_TYPE;
350 // This method binding is append(float)
351 return APPEND_FLOAT_METHOD_NAME_AND_TYPE;
353 // This method binding is append(long)
354 return APPEND_LONG_METHOD_NAME_AND_TYPE;
355 case T_JavaLangObject :
356 // This method binding is append(java.lang.Object)
357 return APPEND_OBJECT_METHOD_NAME_AND_TYPE;
359 // This method binding is append(char)
360 return APPEND_CHAR_METHOD_NAME_AND_TYPE;
361 case T_JavaLangString :
362 // This method binding is append(java.lang.String)
363 return APPEND_STRING_METHOD_NAME_AND_TYPE;
365 // This method binding is append(boolean)
366 return APPEND_BOOLEAN_METHOD_NAME_AND_TYPE;
368 // This method binding is append(double)
369 return APPEND_DOUBLE_METHOD_NAME_AND_TYPE;
374 if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
375 // This method binding is toString()
376 return TOSTRING_METHOD_NAME_AND_TYPE;
380 if ((methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
381 switch(methodBinding.parameters[0].id) {
383 return VALUEOF_OBJECT_METHOD_NAME_AND_TYPE;
387 return VALUEOF_INT_METHOD_NAME_AND_TYPE;
389 return VALUEOF_LONG_METHOD_NAME_AND_TYPE;
391 return VALUEOF_FLOAT_METHOD_NAME_AND_TYPE;
393 return VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE;
395 return VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE;
397 return VALUEOF_CHAR_METHOD_NAME_AND_TYPE;
402 if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
403 // This method binding is exit(int)
404 return EXIT_METHOD_NAME_AND_TYPE;
408 if ((methodBinding.selector.length == 10)
409 && (methodBinding.parameters.length == 0)
410 && (methodBinding.returnType.id == T_JavaLangString)
411 && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
412 // This method binding is getMessage()
413 return GETMESSAGE_METHOD_NAME_AND_TYPE;
415 if (methodBinding.parameters.length == 0
416 && methodBinding.returnType.id == T_JavaLangClass
417 && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
418 return GETCLASS_OBJECT_METHOD_NAME_AND_TYPE;
420 if (methodBinding.parameters.length == 0
421 && methodBinding.returnType.id == T_JavaLangClass
422 && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetComponentType)) {
423 return GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE;
427 if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
428 // This method binding is toString()
429 return INTERN_METHOD_NAME_AND_TYPE;
435 * Return the index of the @methodBinding.
437 * Returns -1 if the @methodBinding is not a predefined methodBinding,
438 * the right index otherwise.
440 * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
441 * @return <CODE>int</CODE>
443 public int indexOfWellKnownMethods(MethodBinding methodBinding) {
444 char firstChar = methodBinding.selector[0];
445 switch (methodBinding.declaringClass.id) {
446 case T_JavaLangClass :
447 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))) {
448 // This method binding is forName(java.lang.String)
449 return FORNAME_CLASS_METHOD;
450 } else if ((firstChar == 'd') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_boolean) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.DesiredAssertionStatus)) {
451 return DESIREDASSERTIONSTATUS_CLASS_METHOD;
452 } else if ((firstChar == 'g') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangClass) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetComponentType)) {
453 return GETCOMPONENTTYPE_CLASS_METHOD;
456 case T_JavaLangNoClassDefError :
457 if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
458 // This method binding is NoClassDefFoundError(java.lang.String)
459 return NOCLASSDEFFOUNDERROR_CONSTR_METHOD;
462 case T_JavaLangReflectConstructor :
463 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)) {
464 return NEWINSTANCE_CONSTRUCTOR_METHOD;
467 case T_JavaLangStringBuffer :
468 if ((firstChar == 'a') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
469 switch (methodBinding.parameters[0].id) {
473 // This method binding is append(int)
474 return APPEND_INT_METHOD;
476 // This method binding is append(float)
477 return APPEND_FLOAT_METHOD;
479 // This method binding is append(long)
480 return APPEND_LONG_METHOD;
481 case T_JavaLangObject :
482 // This method binding is append(java.lang.Object)
483 return APPEND_OBJECT_METHOD;
485 // This method binding is append(char)
486 return APPEND_CHAR_METHOD;
487 case T_JavaLangString :
488 // This method binding is append(java.lang.String)
489 return APPEND_STRING_METHOD;
491 // This method binding is append(boolean)
492 return APPEND_BOOLEAN_METHOD;
494 // This method binding is append(double)
495 return APPEND_DOUBLE_METHOD;
498 if ((firstChar == 't') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
499 // This method binding is toString()
500 return STRINGBUFFER_TOSTRING_METHOD;
502 if ((firstChar == '<') && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
503 if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString)) {
504 // This method binding is <init>(String)
505 return STRINGBUFFER_STRING_CONSTR_METHOD;
507 if (methodBinding.parameters.length == 0) {
508 // This method binding is <init>()
509 return STRINGBUFFER_DEFAULT_CONSTR_METHOD;
514 case T_JavaLangString :
515 if ((firstChar == 'v') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
516 // This method binding is valueOf(java.lang.Object)
517 switch (methodBinding.parameters[0].id) {
519 return VALUEOF_OBJECT_METHOD;
523 return VALUEOF_INT_METHOD;
525 return VALUEOF_LONG_METHOD;
527 return VALUEOF_FLOAT_METHOD;
529 return VALUEOF_DOUBLE_METHOD;
531 return VALUEOF_BOOLEAN_METHOD;
533 return VALUEOF_CHAR_METHOD;
536 if ((firstChar == 'i') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
537 // This method binding is valueOf(java.lang.Object)
538 return STRING_INTERN_METHOD;
541 case T_JavaLangSystem :
542 if ((firstChar == 'e') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
543 // This method binding is exit(int)
544 return SYSTEM_EXIT_METHOD;
547 case T_JavaLangThrowable :
548 if ((firstChar == 'g') && (methodBinding.selector.length == 10) && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
549 // This method binding is getMessage()
550 return THROWABLE_GETMESSAGE_METHOD;
553 case T_JavaLangError :
554 if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) && (methodBinding.parameters[0].id == T_String)) {
555 return JAVALANGERROR_CONSTR_METHOD;
558 case T_JavaLangAssertionError :
559 if ((firstChar == '<') && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
560 switch (methodBinding.parameters.length) {
562 return ASSERTIONERROR_DEFAULT_CONSTR_METHOD;
564 switch(methodBinding.parameters[0].id) {
566 return ASSERTIONERROR_CONSTR_BOOLEAN_METHOD;
568 return ASSERTIONERROR_CONSTR_CHAR_METHOD;
570 return ASSERTIONERROR_CONSTR_DOUBLE_METHOD;
574 return ASSERTIONERROR_CONSTR_INT_METHOD;
576 return ASSERTIONERROR_CONSTR_FLOAT_METHOD;
578 return ASSERTIONERROR_CONSTR_LONG_METHOD;
580 return ASSERTIONERROR_CONSTR_OBJECT_METHOD;
585 case T_JavaLangObject :
586 if (methodBinding.parameters.length == 0
587 && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
588 return GETCLASS_OBJECT_METHOD;
594 * Return the index of the @typeBinding
596 * Returns -1 if the @typeBinding is not a predefined binding, the right index
599 * @param typeBinding org.eclipse.jdt.internal.compiler.lookup.TypeBinding
600 * @return <CODE>int</CODE>
602 public int indexOfWellKnownTypes(TypeBinding typeBinding) {
603 switch(typeBinding.id) {
604 case T_JavaLangBoolean : return JAVA_LANG_BOOLEAN_TYPE;
605 case T_JavaLangByte : return JAVA_LANG_BYTE_TYPE;
606 case T_JavaLangCharacter : return JAVA_LANG_CHARACTER_TYPE;
607 case T_JavaLangDouble : return JAVA_LANG_DOUBLE_TYPE;
608 case T_JavaLangFloat : return JAVA_LANG_FLOAT_TYPE;
609 case T_JavaLangInteger : return JAVA_LANG_INTEGER_TYPE;
610 case T_JavaLangLong : return JAVA_LANG_LONG_TYPE;
611 case T_JavaLangShort : return JAVA_LANG_SHORT_TYPE;
612 case T_JavaLangVoid : return JAVA_LANG_VOID_TYPE;
613 case T_JavaLangClass : return JAVA_LANG_CLASS_TYPE;
614 case T_JavaLangClassNotFoundException : return JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE;
615 case T_JavaLangNoClassDefError : return JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE;
616 case T_JavaLangObject : return JAVA_LANG_OBJECT_TYPE;
617 case T_JavaLangString : return JAVA_LANG_STRING_TYPE;
618 case T_JavaLangStringBuffer : return JAVA_LANG_STRINGBUFFER_TYPE;
619 case T_JavaLangSystem : return JAVA_LANG_SYSTEM_TYPE;
620 case T_JavaLangThrowable : return JAVA_LANG_THROWABLE_TYPE;
621 case T_JavaLangError : return JAVA_LANG_ERROR_TYPE;
622 case T_JavaLangException : return JAVA_LANG_EXCEPTION_TYPE;
623 case T_JavaLangReflectConstructor : return JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE;
624 case T_JavaLangAssertionError : return JAVA_LANG_ASSERTIONERROR_TYPE;
628 public int literalIndex(byte[] utf8encoding, char[] stringCharArray) {
630 if ((index = UTF8Cache.get(stringCharArray)) < 0) {
631 // The entry doesn't exit yet
632 index = UTF8Cache.put(stringCharArray, currentIndex);
634 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
637 // Write the tag first
639 // Then the size of the stringName array
640 //writeU2(utf8Constant.length);
641 int savedCurrentOffset = currentOffset;
642 int utf8encodingLength = utf8encoding.length;
643 if (currentOffset + 2 + utf8encodingLength >= poolContent.length) {
644 // we need to resize the poolContent array because we won't have
645 // enough space to write the length
646 resizePoolContents(2 + utf8encodingLength);
649 // add in once the whole byte array
650 System.arraycopy(utf8encoding, 0, poolContent, currentOffset, utf8encodingLength);
651 currentOffset += utf8encodingLength;
652 // Now we know the length that we have to write in the constant pool
653 // we use savedCurrentOffset to do that
654 poolContent[savedCurrentOffset] = (byte) (utf8encodingLength >> 8);
655 poolContent[savedCurrentOffset + 1] = (byte) utf8encodingLength;
660 * This method returns the index into the constantPool corresponding to the type descriptor.
662 * @param utf8Constant char[]
663 * @return <CODE>int</CODE>
665 public int literalIndex(char[] utf8Constant) {
667 if ((index = UTF8Cache.get(utf8Constant)) < 0) {
668 // The entry doesn't exit yet
669 // Write the tag first
671 // Then the size of the stringName array
672 int savedCurrentOffset = currentOffset;
673 if (currentOffset + 2 >= poolContent.length) {
674 // we need to resize the poolContent array because we won't have
675 // enough space to write the length
676 resizePoolContents(2);
680 for (int i = 0; i < utf8Constant.length; i++) {
681 char current = utf8Constant[i];
682 if ((current >= 0x0001) && (current <= 0x007F)) {
683 // we only need one byte: ASCII table
687 if (current > 0x07FF) {
690 writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
691 writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
692 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
694 // we can be 0 or between 0x0080 and 0x07FF
695 // In that case we only need 2 bytes
697 writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
698 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
701 if (length >= 65535) {
702 currentOffset = savedCurrentOffset - 1;
703 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceForConstant(this.classFile.referenceBinding.scope.referenceType());
705 index = UTF8Cache.put(utf8Constant, currentIndex);
707 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
710 // Now we know the length that we have to write in the constant pool
711 // we use savedCurrentOffset to do that
712 poolContent[savedCurrentOffset] = (byte) (length >> 8);
713 poolContent[savedCurrentOffset + 1] = (byte) length;
717 public int literalIndex(char[] stringCharArray, byte[] utf8encoding) {
720 if ((index = stringCache.get(stringCharArray)) < 0) {
721 // The entry doesn't exit yet
722 stringIndex = literalIndex(utf8encoding, stringCharArray);
723 index = stringCache.put(stringCharArray, currentIndex++);
725 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
727 // Write the tag first
729 // Then the string index
730 writeU2(stringIndex);
735 * This method returns the index into the constantPool corresponding to the double
736 * value. If the double is not already present into the pool, it is added. The
737 * double cache is updated and it returns the right index.
739 * @param key <CODE>double</CODE>
740 * @return <CODE>int</CODE>
742 public int literalIndex(double key) {
743 //Retrieve the index from the cache
744 // The double constant takes two indexes into the constant pool, but we only store
745 // the first index into the long table
747 // lazy initialization for base type caches
748 // If it is null, initialize it, otherwise use it
749 if (doubleCache == null) {
750 doubleCache = new DoubleCache(DOUBLE_INITIAL_SIZE);
752 if ((index = doubleCache.get(key)) < 0) {
753 index = doubleCache.put(key, currentIndex++);
755 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
757 currentIndex++; // a double needs an extra place into the constant pool
758 // Write the double into the constant pool
761 // Then add the 8 bytes representing the double
762 long temp = java.lang.Double.doubleToLongBits(key);
763 int length = poolContent.length;
764 if (currentOffset + 8 >= length) {
765 resizePoolContents(8);
767 for (int i = 0; i < 8; i++) {
768 poolContent[currentOffset++] = (byte) (temp >>> (56 - (i << 3)));
774 * This method returns the index into the constantPool corresponding to the float
775 * value. If the float is not already present into the pool, it is added. The
776 * int cache is updated and it returns the right index.
778 * @param key <CODE>float</CODE>
779 * @return <CODE>int</CODE>
781 public int literalIndex(float key) {
782 //Retrieve the index from the cache
784 // lazy initialization for base type caches
785 // If it is null, initialize it, otherwise use it
786 if (floatCache == null) {
787 floatCache = new FloatCache(FLOAT_INITIAL_SIZE);
789 if ((index = floatCache.get(key)) < 0) {
790 index = floatCache.put(key, currentIndex++);
792 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
794 // Write the float constant entry into the constant pool
797 // Then add the 4 bytes representing the float
798 int temp = java.lang.Float.floatToIntBits(key);
799 if (currentOffset + 4 >= poolContent.length) {
800 resizePoolContents(4);
802 for (int i = 0; i < 4; i++) {
803 poolContent[currentOffset++] = (byte) (temp >>> (24 - i * 8));
809 * This method returns the index into the constantPool corresponding to the int
810 * value. If the int is not already present into the pool, it is added. The
811 * int cache is updated and it returns the right index.
813 * @param key <CODE>int</CODE>
814 * @return <CODE>int</CODE>
816 public int literalIndex(int key) {
817 //Retrieve the index from the cache
819 // lazy initialization for base type caches
820 // If it is null, initialize it, otherwise use it
821 if (intCache == null) {
822 intCache = new IntegerCache(INT_INITIAL_SIZE);
824 if ((index = intCache.get(key)) < 0) {
825 index = intCache.put(key, currentIndex++);
827 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
829 // Write the integer constant entry into the constant pool
832 // Then add the 4 bytes representing the int
833 if (currentOffset + 4 >= poolContent.length) {
834 resizePoolContents(4);
836 for (int i = 0; i < 4; i++) {
837 poolContent[currentOffset++] = (byte) (key >>> (24 - i * 8));
843 * This method returns the index into the constantPool corresponding to the long
844 * value. If the long is not already present into the pool, it is added. The
845 * long cache is updated and it returns the right index.
847 * @param key <CODE>long</CODE>
848 * @return <CODE>int</CODE>
850 public int literalIndex(long key) {
851 // Retrieve the index from the cache
852 // The long constant takes two indexes into the constant pool, but we only store
853 // the first index into the long table
855 // lazy initialization for base type caches
856 // If it is null, initialize it, otherwise use it
857 if (longCache == null) {
858 longCache = new LongCache(LONG_INITIAL_SIZE);
860 if ((index = longCache.get(key)) < 0) {
861 index = longCache.put(key, currentIndex++);
863 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
865 currentIndex++; // long value need an extra place into thwe constant pool
866 // Write the long into the constant pool
869 // Then add the 8 bytes representing the long
870 if (currentOffset + 8 >= poolContent.length) {
871 resizePoolContents(8);
873 for (int i = 0; i < 8; i++) {
874 poolContent[currentOffset++] = (byte) (key >>> (56 - (i << 3)));
880 * This method returns the index into the constantPool corresponding to the type descriptor.
882 * @param stringConstant java.lang.String
883 * @return <CODE>int</CODE>
885 public int literalIndex(String stringConstant) {
887 char[] stringCharArray = stringConstant.toCharArray();
888 if ((index = stringCache.get(stringCharArray)) < 0) {
889 // The entry doesn't exit yet
890 int stringIndex = literalIndex(stringCharArray);
891 index = stringCache.put(stringCharArray, currentIndex++);
893 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
895 // Write the tag first
897 // Then the string index
898 writeU2(stringIndex);
903 * This method returns the index into the constantPool
904 * corresponding to the field binding aFieldBinding.
906 * @param aFieldBinding FieldBinding
907 * @return <CODE>int</CODE>
909 public int literalIndex(FieldBinding aFieldBinding) {
911 int nameAndTypeIndex;
913 int indexWellKnownField;
914 if ((indexWellKnownField = indexOfWellKnownFields(aFieldBinding)) == -1) {
915 if ((index = fieldCache.get(aFieldBinding)) < 0) {
916 // The entry doesn't exit yet
917 classIndex = literalIndex(aFieldBinding.declaringClass);
918 nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
919 index = fieldCache.put(aFieldBinding, currentIndex++);
921 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
923 writeU1(FieldRefTag);
925 writeU2(nameAndTypeIndex);
928 if ((index = wellKnownFields[indexWellKnownField]) == 0) {
929 // that field need to be inserted
930 classIndex = literalIndex(aFieldBinding.declaringClass);
931 nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
932 index = wellKnownFields[indexWellKnownField] = currentIndex++;
934 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
936 writeU1(FieldRefTag);
938 writeU2(nameAndTypeIndex);
944 * This method returns the index into the constantPool corresponding to the
945 * method descriptor. It can be either an interface method reference constant
946 * or a method reference constant.
947 * Note: uses the method binding #constantPoolDeclaringClass which could be an array type
948 * for the array clone method (see UpdatedMethodDeclaration).
949 * @param aMethodBinding MethodBinding
950 * @return <CODE>int</CODE>
952 public int literalIndex(MethodBinding aMethodBinding) {
954 int nameAndTypeIndex;
956 int indexWellKnownMethod;
957 if ((indexWellKnownMethod = indexOfWellKnownMethods(aMethodBinding)) == -1) {
958 if (aMethodBinding.constantPoolDeclaringClass().isInterface()) {
959 // Lookinf into the interface method ref table
960 if ((index = interfaceMethodCache.get(aMethodBinding)) < 0) {
961 classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
962 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
963 index = interfaceMethodCache.put(aMethodBinding, currentIndex++);
965 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
967 // Write the interface method ref constant into the constant pool
969 writeU1(InterfaceMethodRefTag);
970 // Then write the class index
972 // The write the nameAndType index
973 writeU2(nameAndTypeIndex);
976 // Lookinf into the method ref table
977 if ((index = methodCache.get(aMethodBinding)) < 0) {
978 classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
979 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
980 index = methodCache.put(aMethodBinding, currentIndex++);
982 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
984 // Write the method ref constant into the constant pool
986 writeU1(MethodRefTag);
987 // Then write the class index
989 // The write the nameAndType index
990 writeU2(nameAndTypeIndex);
994 // This is a well known method
995 if ((index = wellKnownMethods[indexWellKnownMethod]) == 0) {
996 // this methods was not inserted yet
997 if (aMethodBinding.constantPoolDeclaringClass().isInterface()) {
998 // Lookinf into the interface method ref table
999 classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
1000 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
1001 index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
1002 if (index > 0xFFFF){
1003 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1005 // Write the interface method ref constant into the constant pool
1006 // First add the tag
1007 writeU1(InterfaceMethodRefTag);
1008 // Then write the class index
1009 writeU2(classIndex);
1010 // The write the nameAndType index
1011 writeU2(nameAndTypeIndex);
1013 // Lookinf into the method ref table
1014 classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
1015 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
1016 index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
1017 if (index > 0xFFFF){
1018 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1020 // Write the method ref constant into the constant pool
1021 // First add the tag
1022 writeU1(MethodRefTag);
1023 // Then write the class index
1024 writeU2(classIndex);
1025 // The write the nameAndType index
1026 writeU2(nameAndTypeIndex);
1033 * This method returns the index into the constantPool corresponding to the type descriptor.
1035 * @param aTypeBinding TypeBinding
1036 * @return <CODE>int</CODE>
1038 public int literalIndex(TypeBinding aTypeBinding) {
1041 int indexWellKnownType;
1042 if ((indexWellKnownType = indexOfWellKnownTypes(aTypeBinding)) == -1) {
1043 if ((index = classCache.get(aTypeBinding)) < 0) {
1044 // The entry doesn't exit yet
1045 nameIndex = literalIndex(aTypeBinding.constantPoolName());
1046 index = classCache.put(aTypeBinding, currentIndex++);
1047 if (index > 0xFFFF){
1048 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1051 // Then add the 8 bytes representing the long
1055 if ((index = wellKnownTypes[indexWellKnownType]) == 0) {
1056 // Need to insert that binding
1057 nameIndex = literalIndex(aTypeBinding.constantPoolName());
1058 index = wellKnownTypes[indexWellKnownType] = currentIndex++;
1059 if (index > 0xFFFF){
1060 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1063 // Then add the 8 bytes representing the long
1070 * This method returns the index into the constantPool corresponding
1071 * nameAndType constant with nameIndex, typeIndex.
1073 * @param nameIndex int
1074 * @param typeIndex int
1075 * @param key org.eclipse.jdt.internal.compiler.lookup.FieldBinding
1076 * @return <CODE>int</CODE>
1078 public int literalIndexForFields(int nameIndex, int typeIndex, FieldBinding key) {
1080 int indexOfWellKnownFieldNameAndType;
1081 if ((indexOfWellKnownFieldNameAndType = indexOfWellKnownFieldNameAndType(key)) == -1) {
1082 // check if the entry already exists
1083 if ((index = nameAndTypeCacheForFields.get(key)) == -1) {
1084 // The entry doesn't exit yet
1085 index = nameAndTypeCacheForFields.put(key, currentIndex++);
1086 if (index > 0xFFFF){
1087 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1089 writeU1(NameAndTypeTag);
1094 if ((index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType]) == 0) {
1095 index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType] = currentIndex++;
1096 if (index > 0xFFFF){
1097 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1099 writeU1(NameAndTypeTag);
1107 * This method returns the index into the constantPool corresponding to the type descriptor.
1109 * @return <CODE>int</CODE>
1111 public int literalIndexForJavaLangBoolean() {
1113 if ((index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE]) == 0) {
1115 // The entry doesn't exit yet
1116 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangBooleanConstantPoolName);
1117 index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE] = currentIndex++;
1118 if (index > 0xFFFF){
1119 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1122 // Then add the 8 bytes representing the long
1128 * This method returns the index into the constantPool
1129 * corresponding to the field binding aFieldBinding.
1131 * @return <CODE>int</CODE>
1133 public int literalIndexForJavaLangBooleanTYPE() {
1135 if ((index = wellKnownFields[TYPE_BOOLEAN_FIELD]) == 0) {
1136 int nameAndTypeIndex;
1138 // The entry doesn't exit yet
1139 classIndex = literalIndexForJavaLangBoolean();
1140 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1141 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1142 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1143 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1144 writeU1(NameAndTypeTag);
1148 index = wellKnownFields[TYPE_BOOLEAN_FIELD] = currentIndex++;
1149 if (index > 0xFFFF){
1150 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1152 writeU1(FieldRefTag);
1153 writeU2(classIndex);
1154 writeU2(nameAndTypeIndex);
1159 * This method returns the index into the constantPool corresponding to the type descriptor.
1161 * @return <CODE>int</CODE>
1163 public int literalIndexForJavaLangByte() {
1165 if ((index = wellKnownTypes[JAVA_LANG_BYTE_TYPE]) == 0) {
1167 // The entry doesn't exit yet
1168 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangByteConstantPoolName);
1169 index = wellKnownTypes[JAVA_LANG_BYTE_TYPE] = currentIndex++;
1170 if (index > 0xFFFF){
1171 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1174 // Then add the 8 bytes representing the long
1180 * This method returns the index into the constantPool
1181 * corresponding to the field binding aFieldBinding.
1183 * @return <CODE>int</CODE>
1185 public int literalIndexForJavaLangByteTYPE() {
1187 if ((index = wellKnownFields[TYPE_BYTE_FIELD]) == 0) {
1188 int nameAndTypeIndex;
1190 // The entry doesn't exit yet
1191 classIndex = literalIndexForJavaLangByte();
1192 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1193 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1194 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1195 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1196 writeU1(NameAndTypeTag);
1200 index = wellKnownFields[TYPE_BYTE_FIELD] = currentIndex++;
1201 if (index > 0xFFFF){
1202 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1204 writeU1(FieldRefTag);
1205 writeU2(classIndex);
1206 writeU2(nameAndTypeIndex);
1211 * This method returns the index into the constantPool corresponding to the type descriptor.
1213 * @return <CODE>int</CODE>
1215 public int literalIndexForJavaLangCharacter() {
1217 if ((index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE]) == 0) {
1219 // The entry doesn't exit yet
1220 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangCharacterConstantPoolName);
1221 index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE] = currentIndex++;
1222 if (index > 0xFFFF){
1223 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1226 // Then add the 8 bytes representing the long
1232 * This method returns the index into the constantPool
1233 * corresponding to the field binding aFieldBinding.
1235 * @return <CODE>int</CODE>
1237 public int literalIndexForJavaLangCharacterTYPE() {
1239 if ((index = wellKnownFields[TYPE_CHARACTER_FIELD]) == 0) {
1240 int nameAndTypeIndex;
1242 // The entry doesn't exit yet
1243 classIndex = literalIndexForJavaLangCharacter();
1244 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1245 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1246 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1247 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1248 writeU1(NameAndTypeTag);
1252 index = wellKnownFields[TYPE_CHARACTER_FIELD] = currentIndex++;
1253 if (index > 0xFFFF){
1254 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1256 writeU1(FieldRefTag);
1257 writeU2(classIndex);
1258 writeU2(nameAndTypeIndex);
1263 * This method returns the index into the constantPool corresponding to the type descriptor.
1265 * @return <CODE>int</CODE>
1267 public int literalIndexForJavaLangClass() {
1269 if ((index = wellKnownTypes[JAVA_LANG_CLASS_TYPE]) == 0) {
1271 // The entry doesn't exit yet
1272 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassConstantPoolName);
1273 index = wellKnownTypes[JAVA_LANG_CLASS_TYPE] = currentIndex++;
1274 if (index > 0xFFFF){
1275 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1278 // Then add the 8 bytes representing the long
1284 * This method returns the index into the constantPool corresponding to the
1285 * method descriptor. It can be either an interface method reference constant
1286 * or a method reference constant.
1288 * @return <CODE>int</CODE>
1290 public int literalIndexForJavaLangClassForName() {
1292 int nameAndTypeIndex;
1294 // Looking into the method ref table
1295 if ((index = wellKnownMethods[FORNAME_CLASS_METHOD]) == 0) {
1296 classIndex = literalIndexForJavaLangClass();
1297 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE]) == 0) {
1298 int nameIndex = literalIndex(QualifiedNamesConstants.ForName);
1299 int typeIndex = literalIndex(QualifiedNamesConstants.ForNameSignature);
1300 nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE] = currentIndex++;
1301 writeU1(NameAndTypeTag);
1305 index = wellKnownMethods[FORNAME_CLASS_METHOD] = currentIndex++;
1306 if (index > 0xFFFF){
1307 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1309 // Write the method ref constant into the constant pool
1310 // First add the tag
1311 writeU1(MethodRefTag);
1312 // Then write the class index
1313 writeU2(classIndex);
1314 // The write the nameAndType index
1315 writeU2(nameAndTypeIndex);
1320 * This method returns the index into the constantPool corresponding to the
1321 * method descriptor. It can be either an interface method reference constant
1322 * or a method reference constant.
1324 * @return <CODE>int</CODE>
1326 public int literalIndexForJavaLangClassDesiredAssertionStatus() {
1328 int nameAndTypeIndex;
1330 // Looking into the method ref table
1331 if ((index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD]) == 0) {
1332 classIndex = literalIndexForJavaLangClass();
1333 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE]) == 0) {
1334 int nameIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatus);
1335 int typeIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatusSignature);
1336 nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE] = currentIndex++;
1337 writeU1(NameAndTypeTag);
1341 index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD] = currentIndex++;
1342 if (index > 0xFFFF){
1343 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1345 // Write the method ref constant into the constant pool
1346 // First add the tag
1347 writeU1(MethodRefTag);
1348 // Then write the class index
1349 writeU2(classIndex);
1350 // The write the nameAndType index
1351 writeU2(nameAndTypeIndex);
1356 * This method returns the index into the constantPool corresponding to the
1357 * method descriptor. It can be either an interface method reference constant
1358 * or a method reference constant.
1360 * @return <CODE>int</CODE>
1362 public int literalIndexForJavaLangClassGetComponentType() {
1364 int nameAndTypeIndex;
1366 // Looking into the method ref table
1367 if ((index = wellKnownMethods[GETCOMPONENTTYPE_CLASS_METHOD]) == 0) {
1368 classIndex = literalIndexForJavaLangClass();
1369 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE]) == 0) {
1370 int nameIndex = literalIndex(QualifiedNamesConstants.GetComponentType);
1371 int typeIndex = literalIndex(QualifiedNamesConstants.GetComponentTypeSignature);
1372 nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE] = currentIndex++;
1373 writeU1(NameAndTypeTag);
1377 index = wellKnownMethods[GETCOMPONENTTYPE_CLASS_METHOD] = currentIndex++;
1378 if (index > 0xFFFF){
1379 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1381 // Write the method ref constant into the constant pool
1382 // First add the tag
1383 writeU1(MethodRefTag);
1384 // Then write the class index
1385 writeU2(classIndex);
1386 // The write the nameAndType index
1387 writeU2(nameAndTypeIndex);
1392 * This method returns the index into the constantPool corresponding to the type descriptor.
1394 * @return <CODE>int</CODE>
1396 public int literalIndexForJavaLangClassNotFoundException() {
1398 if ((index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE]) == 0) {
1400 // The entry doesn't exit yet
1401 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassNotFoundExceptionConstantPoolName);
1402 index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE] = currentIndex++;
1403 if (index > 0xFFFF){
1404 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1407 // Then add the 8 bytes representing the long
1413 * This method returns the index into the constantPool corresponding to the type descriptor.
1415 * @return <CODE>int</CODE>
1417 public int literalIndexForJavaLangDouble() {
1419 if ((index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE]) == 0) {
1421 // The entry doesn't exit yet
1422 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangDoubleConstantPoolName);
1423 index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE] = currentIndex++;
1424 if (index > 0xFFFF){
1425 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1428 // Then add the 8 bytes representing the long
1434 * This method returns the index into the constantPool
1435 * corresponding to the field binding aFieldBinding.
1437 * @return <CODE>int</CODE>
1439 public int literalIndexForJavaLangDoubleTYPE() {
1441 if ((index = wellKnownFields[TYPE_DOUBLE_FIELD]) == 0) {
1442 int nameAndTypeIndex;
1444 // The entry doesn't exit yet
1445 classIndex = literalIndexForJavaLangDouble();
1446 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1447 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1448 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1449 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1450 writeU1(NameAndTypeTag);
1454 index = wellKnownFields[TYPE_DOUBLE_FIELD] = currentIndex++;
1455 if (index > 0xFFFF){
1456 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1458 writeU1(FieldRefTag);
1459 writeU2(classIndex);
1460 writeU2(nameAndTypeIndex);
1465 * This method returns the index into the constantPool corresponding to the type descriptor.
1467 * @return <CODE>int</CODE>
1469 public int literalIndexForJavaLangError() {
1471 if ((index = wellKnownTypes[JAVA_LANG_ERROR_TYPE]) == 0) {
1473 // The entry doesn't exit yet
1474 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangErrorConstantPoolName);
1475 index = wellKnownTypes[JAVA_LANG_ERROR_TYPE] = currentIndex++;
1476 if (index > 0xFFFF){
1477 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1480 // Then add the 8 bytes representing the long
1486 * This method returns the index into the constantPool corresponding to the
1487 * method descriptor. It can be either an interface method reference constant
1488 * or a method reference constant.
1490 * @return <CODE>int</CODE>
1492 public int literalIndexForJavaLangErrorConstructor() {
1494 int nameAndTypeIndex;
1496 // Looking into the method ref table
1497 if ((index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD]) == 0) {
1498 classIndex = literalIndexForJavaLangError();
1499 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
1500 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1501 int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
1502 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
1503 writeU1(NameAndTypeTag);
1507 index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD] = currentIndex++;
1508 if (index > 0xFFFF){
1509 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1511 // Write the method ref constant into the constant pool
1512 // First add the tag
1513 writeU1(MethodRefTag);
1514 // Then write the class index
1515 writeU2(classIndex);
1516 // The write the nameAndType index
1517 writeU2(nameAndTypeIndex);
1521 public int literalIndexForJavaLangException() {
1523 if ((index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE]) == 0) {
1524 // The entry doesn't exit yet
1525 int nameIndex = literalIndex(QualifiedNamesConstants.JavaLangExceptionConstantPoolName);
1526 index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE] = currentIndex++;
1527 if (index > 0xFFFF){
1528 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1531 // Then add the 8 bytes representing the long
1537 * This method returns the index into the constantPool corresponding to the type descriptor.
1539 * @return <CODE>int</CODE>
1541 public int literalIndexForJavaLangFloat() {
1543 if ((index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE]) == 0) {
1545 // The entry doesn't exit yet
1546 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangFloatConstantPoolName);
1547 index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE] = currentIndex++;
1548 if (index > 0xFFFF){
1549 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1552 // Then add the 8 bytes representing the long
1558 * This method returns the index into the constantPool
1559 * corresponding to the field binding aFieldBinding.
1561 * @return <CODE>int</CODE>
1563 public int literalIndexForJavaLangFloatTYPE() {
1565 if ((index = wellKnownFields[TYPE_FLOAT_FIELD]) == 0) {
1566 int nameAndTypeIndex;
1568 // The entry doesn't exit yet
1569 classIndex = literalIndexForJavaLangFloat();
1570 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1571 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1572 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1573 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1574 writeU1(NameAndTypeTag);
1578 index = wellKnownFields[TYPE_FLOAT_FIELD] = currentIndex++;
1579 if (index > 0xFFFF){
1580 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1582 writeU1(FieldRefTag);
1583 writeU2(classIndex);
1584 writeU2(nameAndTypeIndex);
1589 * This method returns the index into the constantPool corresponding to the type descriptor.
1591 * @return <CODE>int</CODE>
1593 public int literalIndexForJavaLangInteger() {
1595 if ((index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE]) == 0) {
1597 // The entry doesn't exit yet
1598 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangIntegerConstantPoolName);
1599 index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE] = currentIndex++;
1600 if (index > 0xFFFF){
1601 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1604 // Then add the 8 bytes representing the long
1610 * This method returns the index into the constantPool
1611 * corresponding to the field binding aFieldBinding.
1613 * @return <CODE>int</CODE>
1615 public int literalIndexForJavaLangIntegerTYPE() {
1617 if ((index = wellKnownFields[TYPE_INTEGER_FIELD]) == 0) {
1618 int nameAndTypeIndex;
1620 // The entry doesn't exit yet
1621 classIndex = literalIndexForJavaLangInteger();
1622 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1623 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1624 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1625 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1626 writeU1(NameAndTypeTag);
1630 index = wellKnownFields[TYPE_INTEGER_FIELD] = currentIndex++;
1631 if (index > 0xFFFF){
1632 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1634 writeU1(FieldRefTag);
1635 writeU2(classIndex);
1636 writeU2(nameAndTypeIndex);
1641 * This method returns the index into the constantPool corresponding to the type descriptor.
1643 * @return <CODE>int</CODE>
1645 public int literalIndexForJavaLangLong() {
1647 if ((index = wellKnownTypes[JAVA_LANG_LONG_TYPE]) == 0) {
1649 // The entry doesn't exit yet
1650 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangLongConstantPoolName);
1651 index = wellKnownTypes[JAVA_LANG_LONG_TYPE] = currentIndex++;
1652 if (index > 0xFFFF){
1653 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1656 // Then add the 8 bytes representing the long
1662 * This method returns the index into the constantPool
1663 * corresponding to the field binding aFieldBinding.
1665 * @return <CODE>int</CODE>
1667 public int literalIndexForJavaLangLongTYPE() {
1669 if ((index = wellKnownFields[TYPE_LONG_FIELD]) == 0) {
1670 int nameAndTypeIndex;
1672 // The entry doesn't exit yet
1673 classIndex = literalIndexForJavaLangLong();
1674 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1675 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1676 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1677 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1678 writeU1(NameAndTypeTag);
1682 index = wellKnownFields[TYPE_LONG_FIELD] = currentIndex++;
1683 if (index > 0xFFFF){
1684 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1686 writeU1(FieldRefTag);
1687 writeU2(classIndex);
1688 writeU2(nameAndTypeIndex);
1693 * This method returns the index into the constantPool corresponding to the type descriptor.
1695 * @return <CODE>int</CODE>
1697 public int literalIndexForJavaLangNoClassDefFoundError() {
1699 if ((index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE]) == 0) {
1701 // The entry doesn't exit yet
1702 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangNoClassDefFoundErrorConstantPoolName);
1703 index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE] = currentIndex++;
1704 if (index > 0xFFFF){
1705 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1708 // Then add the 8 bytes representing the long
1715 * This method returns the index into the constantPool corresponding to the type descriptor.
1717 * @return <CODE>int</CODE>
1719 public int literalIndexForJavaLangAssertionError() {
1721 if ((index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE]) == 0) {
1723 // The entry doesn't exit yet
1724 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangAssertionErrorConstantPoolName);
1725 index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE] = currentIndex++;
1726 if (index > 0xFFFF){
1727 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1730 // Then add the 8 bytes representing the long
1737 * This method returns the index into the constantPool corresponding to the type descriptor.
1739 * @param typeBindingID int
1740 * @return <CODE>int</CODE>
1742 public int literalIndexForJavaLangAssertionErrorConstructor(int typeBindingID) {
1744 int nameAndTypeIndex = 0;
1746 switch (typeBindingID) {
1750 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD]) == 0) {
1751 classIndex = literalIndexForJavaLangAssertionError();
1752 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE]) == 0) {
1753 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1754 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorIntConstrSignature);
1755 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
1756 writeU1(NameAndTypeTag);
1760 index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD] = currentIndex++;
1761 if (index > 0xFFFF){
1762 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1764 // Write the method ref constant into the constant pool
1765 // First add the tag
1766 writeU1(MethodRefTag);
1767 // Then write the class index
1768 writeU2(classIndex);
1769 // The write the nameAndType index
1770 writeU2(nameAndTypeIndex);
1774 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD]) == 0) {
1775 classIndex = literalIndexForJavaLangAssertionError();
1776 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE]) == 0) {
1777 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1778 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorLongConstrSignature);
1779 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
1780 writeU1(NameAndTypeTag);
1784 index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD] = currentIndex++;
1785 if (index > 0xFFFF){
1786 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1788 // Write the method ref constant into the constant pool
1789 // First add the tag
1790 writeU1(MethodRefTag);
1791 // Then write the class index
1792 writeU2(classIndex);
1793 // The write the nameAndType index
1794 writeU2(nameAndTypeIndex);
1798 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD]) == 0) {
1799 classIndex = literalIndexForJavaLangAssertionError();
1800 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
1801 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1802 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorFloatConstrSignature);
1803 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
1804 writeU1(NameAndTypeTag);
1808 index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD] = currentIndex++;
1809 if (index > 0xFFFF){
1810 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1812 // Write the method ref constant into the constant pool
1813 // First add the tag
1814 writeU1(MethodRefTag);
1815 // Then write the class index
1816 writeU2(classIndex);
1817 // The write the nameAndType index
1818 writeU2(nameAndTypeIndex);
1822 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD]) == 0) {
1823 classIndex = literalIndexForJavaLangAssertionError();
1824 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
1825 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1826 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorDoubleConstrSignature);
1827 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
1828 writeU1(NameAndTypeTag);
1832 index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD] = currentIndex++;
1833 if (index > 0xFFFF){
1834 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1836 // Write the method ref constant into the constant pool
1837 // First add the tag
1838 writeU1(MethodRefTag);
1839 // Then write the class index
1840 writeU2(classIndex);
1841 // The write the nameAndType index
1842 writeU2(nameAndTypeIndex);
1846 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD]) == 0) {
1847 classIndex = literalIndexForJavaLangAssertionError();
1848 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
1849 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1850 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorCharConstrSignature);
1851 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
1852 writeU1(NameAndTypeTag);
1856 index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD] = currentIndex++;
1857 if (index > 0xFFFF){
1858 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1860 // Write the method ref constant into the constant pool
1861 // First add the tag
1862 writeU1(MethodRefTag);
1863 // Then write the class index
1864 writeU2(classIndex);
1865 // The write the nameAndType index
1866 writeU2(nameAndTypeIndex);
1870 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD]) == 0) {
1871 classIndex = literalIndexForJavaLangAssertionError();
1872 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
1873 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1874 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorBooleanConstrSignature);
1875 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
1876 writeU1(NameAndTypeTag);
1880 index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD] = currentIndex++;
1881 if (index > 0xFFFF){
1882 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1884 // Write the method ref constant into the constant pool
1885 // First add the tag
1886 writeU1(MethodRefTag);
1887 // Then write the class index
1888 writeU2(classIndex);
1889 // The write the nameAndType index
1890 writeU2(nameAndTypeIndex);
1897 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD]) == 0) {
1898 classIndex = literalIndexForJavaLangAssertionError();
1899 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
1900 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1901 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorObjectConstrSignature);
1902 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
1903 writeU1(NameAndTypeTag);
1907 index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD] = currentIndex++;
1908 if (index > 0xFFFF){
1909 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1911 // Write the method ref constant into the constant pool
1912 // First add the tag
1913 writeU1(MethodRefTag);
1914 // Then write the class index
1915 writeU2(classIndex);
1916 // The write the nameAndType index
1917 writeU2(nameAndTypeIndex);
1924 * This method returns the index into the constantPool corresponding to the
1925 * method descriptor. It can be either an interface method reference constant
1926 * or a method reference constant.
1928 * @return <CODE>int</CODE>
1930 public int literalIndexForJavaLangAssertionErrorDefaultConstructor() {
1932 int nameAndTypeIndex;
1934 // Looking into the method ref table
1935 if ((index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD]) == 0) {
1936 classIndex = literalIndexForJavaLangAssertionError();
1937 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
1938 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1939 int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
1940 nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
1941 writeU1(NameAndTypeTag);
1945 index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD] = currentIndex++;
1946 if (index > 0xFFFF){
1947 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1949 // Write the method ref constant into the constant pool
1950 // First add the tag
1951 writeU1(MethodRefTag);
1952 // Then write the class index
1953 writeU2(classIndex);
1954 // The write the nameAndType index
1955 writeU2(nameAndTypeIndex);
1962 * This method returns the index into the constantPool corresponding to the
1963 * method descriptor. It can be either an interface method reference constant
1964 * or a method reference constant.
1966 * @return <CODE>int</CODE>
1968 public int literalIndexForJavaLangNoClassDefFoundErrorStringConstructor() {
1970 int nameAndTypeIndex;
1972 // Looking into the method ref table
1973 if ((index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD]) == 0) {
1974 classIndex = literalIndexForJavaLangNoClassDefFoundError();
1975 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
1976 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1977 int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
1978 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
1979 writeU1(NameAndTypeTag);
1983 index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD] = currentIndex++;
1984 if (index > 0xFFFF){
1985 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1987 // Write the method ref constant into the constant pool
1988 // First add the tag
1989 writeU1(MethodRefTag);
1990 // Then write the class index
1991 writeU2(classIndex);
1992 // The write the nameAndType index
1993 writeU2(nameAndTypeIndex);
1998 * This method returns the index into the constantPool corresponding to the type descriptor.
2000 * @return <CODE>int</CODE>
2002 public int literalIndexForJavaLangObject() {
2004 if ((index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE]) == 0) {
2006 // The entry doesn't exit yet
2007 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangObjectConstantPoolName);
2008 index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE] = currentIndex++;
2009 if (index > 0xFFFF){
2010 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2013 // Then add the 8 bytes representing the long
2019 * This method returns the index into the constantPool corresponding to the type descriptor.
2021 * @return <CODE>int</CODE>
2023 public int literalIndexForJavaLangReflectConstructor() {
2025 if ((index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE]) == 0) {
2027 // The entry doesn't exit yet
2028 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangReflectConstructor);
2029 index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE] = currentIndex++;
2030 if (index > 0xFFFF){
2031 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2034 // Then add the 8 bytes representing the long
2039 public int literalIndexForJavaLangReflectConstructorNewInstance() {
2041 int nameAndTypeIndex;
2043 // Looking into the method ref table
2044 if ((index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD]) == 0) {
2045 classIndex = literalIndexForJavaLangReflectConstructor();
2046 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE]) == 0) {
2047 int nameIndex = literalIndex(QualifiedNamesConstants.NewInstance);
2048 int typeIndex = literalIndex(QualifiedNamesConstants.NewInstanceSignature);
2049 nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE] = currentIndex++;
2050 writeU1(NameAndTypeTag);
2054 index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD] = currentIndex++;
2055 if (index > 0xFFFF){
2056 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2058 // Write the method ref constant into the constant pool
2059 // First add the tag
2060 writeU1(MethodRefTag);
2061 // Then write the class index
2062 writeU2(classIndex);
2063 // The write the nameAndType index
2064 writeU2(nameAndTypeIndex);
2069 * This method returns the index into the constantPool corresponding to the type descriptor.
2071 * @return <CODE>int</CODE>
2073 public int literalIndexForJavaLangShort() {
2075 if ((index = wellKnownTypes[JAVA_LANG_SHORT_TYPE]) == 0) {
2077 // The entry doesn't exit yet
2078 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangShortConstantPoolName);
2079 index = wellKnownTypes[JAVA_LANG_SHORT_TYPE] = currentIndex++;
2080 if (index > 0xFFFF){
2081 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2084 // Then add the 8 bytes representing the long
2090 * This method returns the index into the constantPool
2091 * corresponding to the field binding aFieldBinding.
2093 * @return <CODE>int</CODE>
2095 public int literalIndexForJavaLangShortTYPE() {
2097 if ((index = wellKnownFields[TYPE_SHORT_FIELD]) == 0) {
2098 int nameAndTypeIndex;
2100 // The entry doesn't exit yet
2101 classIndex = literalIndexForJavaLangShort();
2102 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
2103 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
2104 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
2105 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
2106 writeU1(NameAndTypeTag);
2110 index = wellKnownFields[TYPE_SHORT_FIELD] = currentIndex++;
2111 if (index > 0xFFFF){
2112 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2114 writeU1(FieldRefTag);
2115 writeU2(classIndex);
2116 writeU2(nameAndTypeIndex);
2121 * This method returns the index into the constantPool corresponding to the type descriptor.
2123 * @return <CODE>int</CODE>
2125 public int literalIndexForJavaLangString() {
2127 if ((index = wellKnownTypes[JAVA_LANG_STRING_TYPE]) == 0) {
2129 // The entry doesn't exit yet
2130 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringConstantPoolName);
2131 index = wellKnownTypes[JAVA_LANG_STRING_TYPE] = currentIndex++;
2132 if (index > 0xFFFF){
2133 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2136 // Then add the 8 bytes representing the long
2142 * This method returns the index into the constantPool corresponding to the type descriptor.
2144 * @return <CODE>int</CODE>
2146 public int literalIndexForJavaLangStringBuffer() {
2148 if ((index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE]) == 0) {
2150 // The entry doesn't exit yet
2151 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringBufferConstantPoolName);
2152 index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE] = currentIndex++;
2153 if (index > 0xFFFF){
2154 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2157 // Then add the 8 bytes representing the long
2163 * This method returns the index into the constantPool corresponding to the
2164 * method descriptor. It can be either an interface method reference constant
2165 * or a method reference constant.
2167 * @return <CODE>int</CODE>
2169 public int literalIndexForJavaLangStringBufferAppend(int typeID) {
2171 int nameAndTypeIndex = 0;
2177 if ((index = wellKnownMethods[APPEND_INT_METHOD]) == 0) {
2178 classIndex = literalIndexForJavaLangStringBuffer();
2179 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE]) == 0) {
2180 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2181 int typeIndex = literalIndex(QualifiedNamesConstants.AppendIntSignature);
2182 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
2183 writeU1(NameAndTypeTag);
2187 index = wellKnownMethods[APPEND_INT_METHOD] = currentIndex++;
2188 if (index > 0xFFFF){
2189 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2191 // Write the method ref constant into the constant pool
2192 // First add the tag
2193 writeU1(MethodRefTag);
2194 // Then write the class index
2195 writeU2(classIndex);
2196 // The write the nameAndType index
2197 writeU2(nameAndTypeIndex);
2201 if ((index = wellKnownMethods[APPEND_LONG_METHOD]) == 0) {
2202 classIndex = literalIndexForJavaLangStringBuffer();
2203 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE]) == 0) {
2204 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2205 int typeIndex = literalIndex(QualifiedNamesConstants.AppendLongSignature);
2206 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
2207 writeU1(NameAndTypeTag);
2211 index = wellKnownMethods[APPEND_LONG_METHOD] = currentIndex++;
2212 if (index > 0xFFFF){
2213 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2215 // Write the method ref constant into the constant pool
2216 // First add the tag
2217 writeU1(MethodRefTag);
2218 // Then write the class index
2219 writeU2(classIndex);
2220 // The write the nameAndType index
2221 writeU2(nameAndTypeIndex);
2225 if ((index = wellKnownMethods[APPEND_FLOAT_METHOD]) == 0) {
2226 classIndex = literalIndexForJavaLangStringBuffer();
2227 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
2228 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2229 int typeIndex = literalIndex(QualifiedNamesConstants.AppendFloatSignature);
2230 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
2231 writeU1(NameAndTypeTag);
2235 index = wellKnownMethods[APPEND_FLOAT_METHOD] = currentIndex++;
2236 if (index > 0xFFFF){
2237 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2239 // Write the method ref constant into the constant pool
2240 // First add the tag
2241 writeU1(MethodRefTag);
2242 // Then write the class index
2243 writeU2(classIndex);
2244 // The write the nameAndType index
2245 writeU2(nameAndTypeIndex);
2249 if ((index = wellKnownMethods[APPEND_DOUBLE_METHOD]) == 0) {
2250 classIndex = literalIndexForJavaLangStringBuffer();
2251 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
2252 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2253 int typeIndex = literalIndex(QualifiedNamesConstants.AppendDoubleSignature);
2254 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
2255 writeU1(NameAndTypeTag);
2259 index = wellKnownMethods[APPEND_DOUBLE_METHOD] = currentIndex++;
2260 if (index > 0xFFFF){
2261 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2263 // Write the method ref constant into the constant pool
2264 // First add the tag
2265 writeU1(MethodRefTag);
2266 // Then write the class index
2267 writeU2(classIndex);
2268 // The write the nameAndType index
2269 writeU2(nameAndTypeIndex);
2273 if ((index = wellKnownMethods[APPEND_CHAR_METHOD]) == 0) {
2274 classIndex = literalIndexForJavaLangStringBuffer();
2275 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
2276 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2277 int typeIndex = literalIndex(QualifiedNamesConstants.AppendCharSignature);
2278 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
2279 writeU1(NameAndTypeTag);
2283 index = wellKnownMethods[APPEND_CHAR_METHOD] = currentIndex++;
2284 if (index > 0xFFFF){
2285 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2287 // Write the method ref constant into the constant pool
2288 // First add the tag
2289 writeU1(MethodRefTag);
2290 // Then write the class index
2291 writeU2(classIndex);
2292 // The write the nameAndType index
2293 writeU2(nameAndTypeIndex);
2297 if ((index = wellKnownMethods[APPEND_BOOLEAN_METHOD]) == 0) {
2298 classIndex = literalIndexForJavaLangStringBuffer();
2299 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
2300 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2301 int typeIndex = literalIndex(QualifiedNamesConstants.AppendBooleanSignature);
2302 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
2303 writeU1(NameAndTypeTag);
2307 index = wellKnownMethods[APPEND_BOOLEAN_METHOD] = currentIndex++;
2308 if (index > 0xFFFF){
2309 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2311 // Write the method ref constant into the constant pool
2312 // First add the tag
2313 writeU1(MethodRefTag);
2314 // Then write the class index
2315 writeU2(classIndex);
2316 // The write the nameAndType index
2317 writeU2(nameAndTypeIndex);
2321 if ((index = wellKnownMethods[APPEND_OBJECT_METHOD]) == 0) {
2322 classIndex = literalIndexForJavaLangStringBuffer();
2323 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
2324 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2325 int typeIndex = literalIndex(QualifiedNamesConstants.AppendObjectSignature);
2326 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
2327 writeU1(NameAndTypeTag);
2331 index = wellKnownMethods[APPEND_OBJECT_METHOD] = currentIndex++;
2332 if (index > 0xFFFF){
2333 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2335 // Write the method ref constant into the constant pool
2336 // First add the tag
2337 writeU1(MethodRefTag);
2338 // Then write the class index
2339 writeU2(classIndex);
2340 // The write the nameAndType index
2341 writeU2(nameAndTypeIndex);
2346 if ((index = wellKnownMethods[APPEND_STRING_METHOD]) == 0) {
2347 classIndex = literalIndexForJavaLangStringBuffer();
2348 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2349 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2350 int typeIndex = literalIndex(QualifiedNamesConstants.AppendStringSignature);
2351 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2352 writeU1(NameAndTypeTag);
2356 index = wellKnownMethods[APPEND_STRING_METHOD] = currentIndex++;
2357 if (index > 0xFFFF){
2358 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2360 // Write the method ref constant into the constant pool
2361 // First add the tag
2362 writeU1(MethodRefTag);
2363 // Then write the class index
2364 writeU2(classIndex);
2365 // The write the nameAndType index
2366 writeU2(nameAndTypeIndex);
2373 * This method returns the index into the constantPool corresponding to the
2374 * method descriptor. It can be either an interface method reference constant
2375 * or a method reference constant.
2377 * @return <CODE>int</CODE>
2379 public int literalIndexForJavaLangStringBufferConstructor() {
2381 int nameAndTypeIndex;
2383 // Looking into the method ref table
2384 if ((index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD]) == 0) {
2385 classIndex = literalIndexForJavaLangStringBuffer();
2386 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2387 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2388 int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
2389 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2390 writeU1(NameAndTypeTag);
2394 index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD] = currentIndex++;
2395 if (index > 0xFFFF){
2396 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2398 // Write the method ref constant into the constant pool
2399 // First add the tag
2400 writeU1(MethodRefTag);
2401 // Then write the class index
2402 writeU2(classIndex);
2403 // The write the nameAndType index
2404 writeU2(nameAndTypeIndex);
2409 * This method returns the index into the constantPool corresponding to the
2410 * method descriptor. It can be either an interface method reference constant
2411 * or a method reference constant.
2413 * @return <CODE>int</CODE>
2415 public int literalIndexForJavaLangStringBufferDefaultConstructor() {
2417 int nameAndTypeIndex;
2419 // Looking into the method ref table
2420 if ((index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD]) == 0) {
2421 classIndex = literalIndexForJavaLangStringBuffer();
2422 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
2423 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2424 int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
2425 nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
2426 writeU1(NameAndTypeTag);
2430 index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD] = currentIndex++;
2431 if (index > 0xFFFF){
2432 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2434 // Write the method ref constant into the constant pool
2435 // First add the tag
2436 writeU1(MethodRefTag);
2437 // Then write the class index
2438 writeU2(classIndex);
2439 // The write the nameAndType index
2440 writeU2(nameAndTypeIndex);
2445 * This method returns the index into the constantPool corresponding to the
2446 * method descriptor. It can be either an interface method reference constant
2447 * or a method reference constant.
2449 * @return <CODE>int</CODE>
2451 public int literalIndexForJavaLangStringBufferToString() {
2453 int nameAndTypeIndex;
2455 // Looking into the method ref table
2456 if ((index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD]) == 0) {
2457 classIndex = literalIndexForJavaLangStringBuffer();
2458 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE]) == 0) {
2459 int nameIndex = literalIndex(QualifiedNamesConstants.ToString);
2460 int typeIndex = literalIndex(QualifiedNamesConstants.ToStringSignature);
2461 nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2462 writeU1(NameAndTypeTag);
2466 index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD] = currentIndex++;
2467 if (index > 0xFFFF){
2468 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2470 // Write the method ref constant into the constant pool
2471 // First add the tag
2472 writeU1(MethodRefTag);
2473 // Then write the class index
2474 writeU2(classIndex);
2475 // The write the nameAndType index
2476 writeU2(nameAndTypeIndex);
2481 * This method returns the index into the constantPool corresponding to the
2482 * method descriptor. It can be either an interface method reference constant
2483 * or a method reference constant.
2485 * @return <CODE>int</CODE>
2487 public int literalIndexForJavaLangStringIntern() {
2489 int nameAndTypeIndex;
2491 // Looking into the method ref table
2492 if ((index = wellKnownMethods[STRING_INTERN_METHOD]) == 0) {
2493 classIndex = literalIndexForJavaLangString();
2494 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE]) == 0) {
2495 int nameIndex = literalIndex(QualifiedNamesConstants.Intern);
2496 int typeIndex = literalIndex(QualifiedNamesConstants.InternSignature);
2497 nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE] = currentIndex++;
2498 writeU1(NameAndTypeTag);
2502 index = wellKnownMethods[STRING_INTERN_METHOD] = currentIndex++;
2503 if (index > 0xFFFF){
2504 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2506 // Write the method ref constant into the constant pool
2507 // First add the tag
2508 writeU1(MethodRefTag);
2509 // Then write the class index
2510 writeU2(classIndex);
2511 // The write the nameAndType index
2512 writeU2(nameAndTypeIndex);
2517 * This method returns the index into the constantPool corresponding to the
2518 * method descriptor. It can be either an interface method reference constant
2519 * or a method reference constant.
2521 * @return <CODE>int</CODE>
2523 public int literalIndexForJavaLangStringValueOf(int typeID) {
2525 int nameAndTypeIndex = 0;
2526 int classIndex = literalIndexForJavaLangString();
2531 if ((index = wellKnownMethods[VALUEOF_INT_METHOD]) == 0) {
2532 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE]) == 0) {
2533 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2534 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfIntSignature);
2535 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
2536 writeU1(NameAndTypeTag);
2540 index = wellKnownMethods[VALUEOF_INT_METHOD] = currentIndex++;
2541 if (index > 0xFFFF){
2542 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2544 // Write the method ref constant into the constant pool
2545 // First add the tag
2546 writeU1(MethodRefTag);
2547 // Then write the class index
2548 writeU2(classIndex);
2549 // The write the nameAndType index
2550 writeU2(nameAndTypeIndex);
2554 if ((index = wellKnownMethods[VALUEOF_LONG_METHOD]) == 0) {
2555 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE]) == 0) {
2556 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2557 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfLongSignature);
2558 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
2559 writeU1(NameAndTypeTag);
2563 index = wellKnownMethods[VALUEOF_LONG_METHOD] = currentIndex++;
2564 if (index > 0xFFFF){
2565 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2567 // Write the method ref constant into the constant pool
2568 // First add the tag
2569 writeU1(MethodRefTag);
2570 // Then write the class index
2571 writeU2(classIndex);
2572 // The write the nameAndType index
2573 writeU2(nameAndTypeIndex);
2577 if ((index = wellKnownMethods[VALUEOF_FLOAT_METHOD]) == 0) {
2578 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
2579 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2580 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfFloatSignature);
2581 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
2582 writeU1(NameAndTypeTag);
2586 index = wellKnownMethods[VALUEOF_FLOAT_METHOD] = currentIndex++;
2587 if (index > 0xFFFF){
2588 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2590 // Write the method ref constant into the constant pool
2591 // First add the tag
2592 writeU1(MethodRefTag);
2593 // Then write the class index
2594 writeU2(classIndex);
2595 // The write the nameAndType index
2596 writeU2(nameAndTypeIndex);
2600 if ((index = wellKnownMethods[VALUEOF_DOUBLE_METHOD]) == 0) {
2601 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
2602 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2603 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfDoubleSignature);
2604 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
2605 writeU1(NameAndTypeTag);
2609 index = wellKnownMethods[VALUEOF_DOUBLE_METHOD] = currentIndex++;
2610 if (index > 0xFFFF){
2611 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2613 // Write the method ref constant into the constant pool
2614 // First add the tag
2615 writeU1(MethodRefTag);
2616 // Then write the class index
2617 writeU2(classIndex);
2618 // The write the nameAndType index
2619 writeU2(nameAndTypeIndex);
2623 if ((index = wellKnownMethods[VALUEOF_CHAR_METHOD]) == 0) {
2624 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
2625 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2626 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfCharSignature);
2627 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
2628 writeU1(NameAndTypeTag);
2632 index = wellKnownMethods[VALUEOF_CHAR_METHOD] = currentIndex++;
2633 if (index > 0xFFFF){
2634 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2636 // Write the method ref constant into the constant pool
2637 // First add the tag
2638 writeU1(MethodRefTag);
2639 // Then write the class index
2640 writeU2(classIndex);
2641 // The write the nameAndType index
2642 writeU2(nameAndTypeIndex);
2646 if ((index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD]) == 0) {
2647 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
2648 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2649 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfBooleanSignature);
2650 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
2651 writeU1(NameAndTypeTag);
2655 index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD] = currentIndex++;
2656 if (index > 0xFFFF){
2657 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2659 // Write the method ref constant into the constant pool
2660 // First add the tag
2661 writeU1(MethodRefTag);
2662 // Then write the class index
2663 writeU2(classIndex);
2664 // The write the nameAndType index
2665 writeU2(nameAndTypeIndex);
2669 if ((index = wellKnownMethods[VALUEOF_OBJECT_METHOD]) == 0) {
2670 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
2671 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2672 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfObjectSignature);
2673 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
2674 writeU1(NameAndTypeTag);
2678 index = wellKnownMethods[VALUEOF_OBJECT_METHOD] = currentIndex++;
2679 if (index > 0xFFFF){
2680 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2682 // Write the method ref constant into the constant pool
2683 // First add the tag
2684 writeU1(MethodRefTag);
2685 // Then write the class index
2686 writeU2(classIndex);
2687 // The write the nameAndType index
2688 writeU2(nameAndTypeIndex);
2695 * This method returns the index into the constantPool corresponding to the type descriptor.
2697 * @return <CODE>int</CODE>
2699 public int literalIndexForJavaLangSystem() {
2701 if ((index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE]) == 0) {
2703 // The entry doesn't exit yet
2704 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangSystemConstantPoolName);
2705 index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE] = currentIndex++;
2706 if (index > 0xFFFF){
2707 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2710 // Then add the 8 bytes representing the long
2716 * This method returns the index into the constantPool corresponding to the
2717 * method descriptor. It can be either an interface method reference constant
2718 * or a method reference constant.
2720 * @return <CODE>int</CODE>
2722 public int literalIndexForJavaLangSystemExitInt() {
2724 int nameAndTypeIndex;
2726 // Looking into the method ref table
2727 if ((index = wellKnownMethods[SYSTEM_EXIT_METHOD]) == 0) {
2728 classIndex = literalIndexForJavaLangSystem();
2729 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE]) == 0) {
2730 int nameIndex = literalIndex(QualifiedNamesConstants.Exit);
2731 int typeIndex = literalIndex(QualifiedNamesConstants.ExitIntSignature);
2732 nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE] = currentIndex++;
2733 writeU1(NameAndTypeTag);
2737 index = wellKnownMethods[SYSTEM_EXIT_METHOD] = currentIndex++;
2738 if (index > 0xFFFF){
2739 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2741 // Write the method ref constant into the constant pool
2742 // First add the tag
2743 writeU1(MethodRefTag);
2744 // Then write the class index
2745 writeU2(classIndex);
2746 // The write the nameAndType index
2747 writeU2(nameAndTypeIndex);
2752 * This method returns the index into the constantPool
2753 * corresponding to the field binding aFieldBinding.
2755 * @return <CODE>int</CODE>
2757 public int literalIndexForJavaLangSystemOut() {
2759 if ((index = wellKnownFields[OUT_SYSTEM_FIELD]) == 0) {
2760 int nameAndTypeIndex;
2762 // The entry doesn't exit yet
2763 classIndex = literalIndexForJavaLangSystem();
2764 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE]) == 0) {
2765 int nameIndex = literalIndex(QualifiedNamesConstants.Out);
2766 int typeIndex = literalIndex(QualifiedNamesConstants.JavaIoPrintStreamSignature);
2767 nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE] = currentIndex++;
2768 writeU1(NameAndTypeTag);
2772 index = wellKnownFields[OUT_SYSTEM_FIELD] = currentIndex++;
2773 if (index > 0xFFFF){
2774 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2776 writeU1(FieldRefTag);
2777 writeU2(classIndex);
2778 writeU2(nameAndTypeIndex);
2783 * This method returns the index into the constantPool corresponding to the type descriptor.
2785 * @return <CODE>int</CODE>
2787 public int literalIndexForJavaLangThrowable() {
2789 if ((index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE]) == 0) {
2791 // The entry doesn't exit yet
2792 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangThrowableConstantPoolName);
2793 index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE] = currentIndex++;
2794 if (index > 0xFFFF){
2795 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2798 // Then add the 8 bytes representing the long
2804 * This method returns the index into the constantPool corresponding to the
2805 * method descriptor. It can be either an interface method reference constant
2806 * or a method reference constant.
2808 * @return <CODE>int</CODE>
2810 public int literalIndexForJavaLangThrowableGetMessage() {
2812 int nameAndTypeIndex;
2814 // Looking into the method ref table
2815 if ((index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD]) == 0) {
2816 classIndex = literalIndexForJavaLangThrowable();
2817 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE]) == 0) {
2818 int nameIndex = literalIndex(QualifiedNamesConstants.GetMessage);
2819 int typeIndex = literalIndex(QualifiedNamesConstants.GetMessageSignature);
2820 nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE] = currentIndex++;
2821 writeU1(NameAndTypeTag);
2825 index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD] = currentIndex++;
2826 if (index > 0xFFFF){
2827 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2829 // Write the method ref constant into the constant pool
2830 // First add the tag
2831 writeU1(MethodRefTag);
2832 // Then write the class index
2833 writeU2(classIndex);
2834 // The write the nameAndType index
2835 writeU2(nameAndTypeIndex);
2840 * This method returns the index into the constantPool corresponding to the type descriptor.
2842 * @return <CODE>int</CODE>
2844 public int literalIndexForJavaLangVoid() {
2846 if ((index = wellKnownTypes[JAVA_LANG_VOID_TYPE]) == 0) {
2848 // The entry doesn't exit yet
2849 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangVoidConstantPoolName);
2850 index = wellKnownTypes[JAVA_LANG_VOID_TYPE] = currentIndex++;
2851 if (index > 0xFFFF){
2852 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2855 // Then add the 8 bytes representing the long
2861 * This method returns the index into the constantPool
2862 * corresponding to the field binding aFieldBinding.
2864 * @return <CODE>int</CODE>
2866 public int literalIndexForJavaLangVoidTYPE() {
2868 if ((index = wellKnownFields[TYPE_VOID_FIELD]) == 0) {
2869 int nameAndTypeIndex;
2871 // The entry doesn't exit yet
2872 classIndex = literalIndexForJavaLangVoid();
2873 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
2874 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
2875 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
2876 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
2877 writeU1(NameAndTypeTag);
2881 index = wellKnownFields[TYPE_VOID_FIELD] = currentIndex++;
2882 if (index > 0xFFFF){
2883 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2885 writeU1(FieldRefTag);
2886 writeU2(classIndex);
2887 writeU2(nameAndTypeIndex);
2892 * This method returns the index into the constantPool corresponding to the type descriptor.
2894 * @param stringCharArray char[]
2895 * @return <CODE>int</CODE>
2897 public int literalIndexForLdc(char[] stringCharArray) {
2899 if ((index = stringCache.get(stringCharArray)) < 0) {
2901 // The entry doesn't exit yet
2902 if ((stringIndex = UTF8Cache.get(stringCharArray)) < 0) {
2903 // The entry doesn't exit yet
2904 // Write the tag first
2906 // Then the size of the stringName array
2907 int savedCurrentOffset = currentOffset;
2908 if (currentOffset + 2 >= poolContent.length) {
2909 // we need to resize the poolContent array because we won't have
2910 // enough space to write the length
2911 resizePoolContents(2);
2915 for (int i = 0; i < stringCharArray.length; i++) {
2916 char current = stringCharArray[i];
2917 if ((current >= 0x0001) && (current <= 0x007F)) {
2918 // we only need one byte: ASCII table
2922 if (current > 0x07FF) {
2925 writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
2926 writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
2927 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
2929 // we can be 0 or between 0x0080 and 0x07FF
2930 // In that case we only need 2 bytes
2932 writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
2933 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
2936 if (length >= 65535) {
2937 currentOffset = savedCurrentOffset - 1;
2940 stringIndex = UTF8Cache.put(stringCharArray, currentIndex++);
2941 // Now we know the length that we have to write in the constant pool
2942 // we use savedCurrentOffset to do that
2943 if (length > 65535) {
2946 poolContent[savedCurrentOffset] = (byte) (length >> 8);
2947 poolContent[savedCurrentOffset + 1] = (byte) length;
2949 index = stringCache.put(stringCharArray, currentIndex++);
2950 if (index > 0xFFFF){
2951 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2953 // Write the tag first
2955 // Then the string index
2956 writeU2(stringIndex);
2961 * This method returns the index into the constantPool corresponding
2962 * nameAndType constant with nameIndex, typeIndex.
2964 * @param nameIndex int
2965 * @param typeIndex int
2966 * @param key org.eclipse.jdt.internal.compiler.lookup.MethodBinding
2967 * @return <CODE>int</CODE>
2969 public int literalIndexForMethods(int nameIndex, int typeIndex, MethodBinding key) {
2971 int indexOfWellKnownMethodNameAndType;
2972 if ((indexOfWellKnownMethodNameAndType = indexOfWellKnownMethodNameAndType(key)) == -1) {
2973 // check if the entry exists
2974 if ((index = nameAndTypeCacheForMethods.get(key)) == -1) {
2975 // The entry doesn't exit yet
2976 index = nameAndTypeCacheForMethods.put(key, currentIndex++);
2977 if (index > 0xFFFF){
2978 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2980 writeU1(NameAndTypeTag);
2985 if ((index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType]) == 0) {
2986 index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType] = currentIndex++;
2987 if (index > 0xFFFF){
2988 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2990 writeU1(NameAndTypeTag);
2998 * This method returns the index into the constantPool corresponding to the
2999 * method descriptor. It can be either an interface method reference constant
3000 * or a method reference constant.
3002 * @return <CODE>int</CODE>
3004 public int literalIndexForJavaLangObjectGetClass() {
3006 int nameAndTypeIndex;
3008 // Looking into the method ref table
3009 if ((index = wellKnownMethods[GETCLASS_OBJECT_METHOD]) == 0) {
3010 classIndex = literalIndexForJavaLangObject();
3011 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
3012 int nameIndex = literalIndex(QualifiedNamesConstants.GetClass);
3013 int typeIndex = literalIndex(QualifiedNamesConstants.GetClassSignature);
3014 nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
3015 writeU1(NameAndTypeTag);
3019 index = wellKnownMethods[GETCLASS_OBJECT_METHOD] = currentIndex++;
3020 // Write the method ref constant into the constant pool
3021 // First add the tag
3022 writeU1(MethodRefTag);
3023 // Then write the class index
3024 writeU2(classIndex);
3025 // The write the nameAndType index
3026 writeU2(nameAndTypeIndex);
3031 * This method is used to clean the receiver in case of a clinit header is generated, but the
3032 * clinit has no code.
3033 * This implementation assumes that the clinit is the first method to be generated.
3034 * @see org.eclipse.jdt.internal.compiler.ast.TypeDeclaration#addClinit()
3036 public void resetForClinit(int constantPoolIndex, int constantPoolOffset) {
3037 currentIndex = constantPoolIndex;
3038 currentOffset = constantPoolOffset;
3039 if (UTF8Cache.get(AttributeNamesConstants.CodeName) >= constantPoolIndex) {
3040 UTF8Cache.remove(AttributeNamesConstants.CodeName);
3042 if (UTF8Cache.get(QualifiedNamesConstants.ClinitSignature) >= constantPoolIndex) {
3043 UTF8Cache.remove(QualifiedNamesConstants.ClinitSignature);
3045 if (UTF8Cache.get(QualifiedNamesConstants.Clinit) >= constantPoolIndex) {
3046 UTF8Cache.remove(QualifiedNamesConstants.Clinit);
3051 * Resize the pool contents
3053 private final void resizePoolContents(int minimalSize) {
3054 int length = poolContent.length;
3056 if (toAdd < minimalSize)
3057 toAdd = minimalSize;
3058 System.arraycopy(poolContent, 0, poolContent = new byte[length + toAdd], 0, length);
3061 * Write a unsigned byte into the byte array
3063 * @param value <CODE>int</CODE> The value to write into the byte array
3065 protected final void writeU1(int value) {
3066 if (currentOffset + 1 >= poolContent.length) {
3067 resizePoolContents(1);
3069 poolContent[currentOffset++] = (byte) value;
3072 * Write a unsigned byte into the byte array
3074 * @param value <CODE>int</CODE> The value to write into the byte array
3076 protected final void writeU2(int value) {
3077 if (currentOffset + 2 >= poolContent.length) {
3078 resizePoolContents(2);
3081 poolContent[currentOffset++] = (byte) (value >> 8);
3082 poolContent[currentOffset++] = (byte) value;