1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.codegen;
13 import net.sourceforge.phpdt.internal.compiler.ClassFile;
15 import net.sourceforge.phpdt.internal.compiler.classfmt.ClassFileConstants;
16 import net.sourceforge.phpdt.internal.compiler.lookup.*;
17 import net.sourceforge.phpdt.internal.compiler.util.*;
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 GETCONSTRUCTOR_CLASS_METHOD = 16;
108 final static int NEWINSTANCE_CONSTRUCTOR_METHOD = 17;
109 final static int STRING_INTERN_METHOD = 18;
110 final static int VALUEOF_INT_METHOD = 19;
111 final static int VALUEOF_FLOAT_METHOD = 20;
112 final static int VALUEOF_LONG_METHOD = 21;
113 final static int VALUEOF_OBJECT_METHOD = 22;
114 final static int VALUEOF_CHAR_METHOD = 23;
115 final static int VALUEOF_BOOLEAN_METHOD = 24;
116 final static int VALUEOF_DOUBLE_METHOD = 25;
117 final static int ASSERTIONERROR_CONSTR_OBJECT_METHOD = 26;
118 final static int ASSERTIONERROR_CONSTR_INT_METHOD = 27;
119 final static int ASSERTIONERROR_CONSTR_LONG_METHOD = 28;
120 final static int ASSERTIONERROR_CONSTR_FLOAT_METHOD = 29;
121 final static int ASSERTIONERROR_CONSTR_DOUBLE_METHOD = 30;
122 final static int ASSERTIONERROR_CONSTR_BOOLEAN_METHOD = 31;
123 final static int ASSERTIONERROR_CONSTR_CHAR_METHOD = 32;
124 final static int ASSERTIONERROR_DEFAULT_CONSTR_METHOD = 33;
125 final static int DESIREDASSERTIONSTATUS_CLASS_METHOD = 34;
126 final static int GETCLASS_OBJECT_METHOD = 35;
127 // predefined constant index for well known name and type for fields
128 final static int TYPE_JAVALANGCLASS_NAME_AND_TYPE = 0;
129 final static int OUT_SYSTEM_NAME_AND_TYPE = 1;
130 // predefined constant index for well known name and type for methods
131 final static int FORNAME_CLASS_METHOD_NAME_AND_TYPE = 0;
132 final static int CONSTR_STRING_METHOD_NAME_AND_TYPE = 1;
133 final static int DEFAULT_CONSTR_METHOD_NAME_AND_TYPE = 2;
134 final static int APPEND_INT_METHOD_NAME_AND_TYPE = 3;
135 final static int APPEND_FLOAT_METHOD_NAME_AND_TYPE = 4;
136 final static int APPEND_LONG_METHOD_NAME_AND_TYPE = 5;
137 final static int APPEND_OBJECT_METHOD_NAME_AND_TYPE = 6;
138 final static int APPEND_CHAR_METHOD_NAME_AND_TYPE = 7;
139 final static int APPEND_STRING_METHOD_NAME_AND_TYPE = 8;
140 final static int APPEND_BOOLEAN_METHOD_NAME_AND_TYPE = 9;
141 final static int APPEND_DOUBLE_METHOD_NAME_AND_TYPE = 10;
142 final static int TOSTRING_METHOD_NAME_AND_TYPE = 11;
143 final static int EXIT_METHOD_NAME_AND_TYPE = 12;
144 final static int GETMESSAGE_METHOD_NAME_AND_TYPE = 13;
145 final static int GETCONSTRUCTOR_METHOD_NAME_AND_TYPE = 14;
146 final static int NEWINSTANCE_METHOD_NAME_AND_TYPE = 15;
147 final static int INTERN_METHOD_NAME_AND_TYPE = 16;
148 final static int VALUEOF_INT_METHOD_NAME_AND_TYPE = 17;
149 final static int VALUEOF_FLOAT_METHOD_NAME_AND_TYPE = 18;
150 final static int VALUEOF_LONG_METHOD_NAME_AND_TYPE = 19;
151 final static int VALUEOF_OBJECT_METHOD_NAME_AND_TYPE = 20;
152 final static int VALUEOF_CHAR_METHOD_NAME_AND_TYPE = 21;
153 final static int VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE = 22;
154 final static int VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE = 23;
155 final static int CONSTR_INT_METHOD_NAME_AND_TYPE = 24;
156 final static int CONSTR_LONG_METHOD_NAME_AND_TYPE = 25;
157 final static int CONSTR_FLOAT_METHOD_NAME_AND_TYPE = 26;
158 final static int CONSTR_DOUBLE_METHOD_NAME_AND_TYPE = 27;
159 final static int CONSTR_OBJECT_METHOD_NAME_AND_TYPE = 28;
160 final static int CONSTR_CHAR_METHOD_NAME_AND_TYPE = 29;
161 final static int CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE = 30;
162 final static int DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE = 31;
163 final static int GETCLASS_OBJECT_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;
422 if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
423 // This method binding is toString()
424 return INTERN_METHOD_NAME_AND_TYPE;
430 * Return the index of the @methodBinding.
432 * Returns -1 if the @methodBinding is not a predefined methodBinding,
433 * the right index otherwise.
435 * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
436 * @return <CODE>int</CODE>
438 public int indexOfWellKnownMethods(MethodBinding methodBinding) {
439 char firstChar = methodBinding.selector[0];
440 switch (methodBinding.declaringClass.id) {
441 case T_JavaLangClass :
442 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))) {
443 // This method binding is forName(java.lang.String)
444 return FORNAME_CLASS_METHOD;
445 } else if ((firstChar == 'g') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangReflectConstructor) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetConstructor) && CharOperation.equals(methodBinding.parameters[0].constantPoolName(), QualifiedNamesConstants.ArrayJavaLangClassConstantPoolName)) {
446 return GETCONSTRUCTOR_CLASS_METHOD;
447 } else if ((firstChar == 'd') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_boolean) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.DesiredAssertionStatus)) {
448 return DESIREDASSERTIONSTATUS_CLASS_METHOD;
451 case T_JavaLangNoClassDefError :
452 if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
453 // This method binding is NoClassDefFoundError(java.lang.String)
454 return NOCLASSDEFFOUNDERROR_CONSTR_METHOD;
457 case T_JavaLangReflectConstructor :
458 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)) {
459 return NEWINSTANCE_CONSTRUCTOR_METHOD;
462 case T_JavaLangStringBuffer :
463 if ((firstChar == 'a') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
464 switch (methodBinding.parameters[0].id) {
468 // This method binding is append(int)
469 return APPEND_INT_METHOD;
471 // This method binding is append(float)
472 return APPEND_FLOAT_METHOD;
474 // This method binding is append(long)
475 return APPEND_LONG_METHOD;
476 case T_JavaLangObject :
477 // This method binding is append(java.lang.Object)
478 return APPEND_OBJECT_METHOD;
480 // This method binding is append(char)
481 return APPEND_CHAR_METHOD;
482 case T_JavaLangString :
483 // This method binding is append(java.lang.String)
484 return APPEND_STRING_METHOD;
486 // This method binding is append(boolean)
487 return APPEND_BOOLEAN_METHOD;
489 // This method binding is append(double)
490 return APPEND_DOUBLE_METHOD;
493 if ((firstChar == 't') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
494 // This method binding is toString()
495 return STRINGBUFFER_TOSTRING_METHOD;
497 if ((firstChar == '<') && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
498 if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString)) {
499 // This method binding is <init>(String)
500 return STRINGBUFFER_STRING_CONSTR_METHOD;
502 if (methodBinding.parameters.length == 0) {
503 // This method binding is <init>()
504 return STRINGBUFFER_DEFAULT_CONSTR_METHOD;
509 case T_JavaLangString :
510 if ((firstChar == 'v') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
511 // This method binding is valueOf(java.lang.Object)
512 switch (methodBinding.parameters[0].id) {
514 return VALUEOF_OBJECT_METHOD;
518 return VALUEOF_INT_METHOD;
520 return VALUEOF_LONG_METHOD;
522 return VALUEOF_FLOAT_METHOD;
524 return VALUEOF_DOUBLE_METHOD;
526 return VALUEOF_BOOLEAN_METHOD;
528 return VALUEOF_CHAR_METHOD;
531 if ((firstChar == 'i') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
532 // This method binding is valueOf(java.lang.Object)
533 return STRING_INTERN_METHOD;
536 case T_JavaLangSystem :
537 if ((firstChar == 'e') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
538 // This method binding is exit(int)
539 return SYSTEM_EXIT_METHOD;
542 case T_JavaLangThrowable :
543 if ((firstChar == 'g') && (methodBinding.selector.length == 10) && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
544 // This method binding is getMessage()
545 return THROWABLE_GETMESSAGE_METHOD;
548 case T_JavaLangError :
549 if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) && (methodBinding.parameters[0].id == T_String)) {
550 return JAVALANGERROR_CONSTR_METHOD;
553 case T_JavaLangAssertionError :
554 if ((firstChar == '<') && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
555 switch (methodBinding.parameters.length) {
557 return ASSERTIONERROR_DEFAULT_CONSTR_METHOD;
559 switch(methodBinding.parameters[0].id) {
561 return ASSERTIONERROR_CONSTR_BOOLEAN_METHOD;
563 return ASSERTIONERROR_CONSTR_CHAR_METHOD;
565 return ASSERTIONERROR_CONSTR_DOUBLE_METHOD;
569 return ASSERTIONERROR_CONSTR_INT_METHOD;
571 return ASSERTIONERROR_CONSTR_FLOAT_METHOD;
573 return ASSERTIONERROR_CONSTR_LONG_METHOD;
575 return ASSERTIONERROR_CONSTR_OBJECT_METHOD;
580 case T_JavaLangObject :
581 if (methodBinding.parameters.length == 0
582 && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
583 return GETCLASS_OBJECT_METHOD;
589 * Return the index of the @typeBinding
591 * Returns -1 if the @typeBinding is not a predefined binding, the right index
594 * @param typeBinding org.eclipse.jdt.internal.compiler.lookup.TypeBinding
595 * @return <CODE>int</CODE>
597 public int indexOfWellKnownTypes(TypeBinding typeBinding) {
598 switch(typeBinding.id) {
599 case T_JavaLangBoolean : return JAVA_LANG_BOOLEAN_TYPE;
600 case T_JavaLangByte : return JAVA_LANG_BYTE_TYPE;
601 case T_JavaLangCharacter : return JAVA_LANG_CHARACTER_TYPE;
602 case T_JavaLangDouble : return JAVA_LANG_DOUBLE_TYPE;
603 case T_JavaLangFloat : return JAVA_LANG_FLOAT_TYPE;
604 case T_JavaLangInteger : return JAVA_LANG_INTEGER_TYPE;
605 case T_JavaLangLong : return JAVA_LANG_LONG_TYPE;
606 case T_JavaLangShort : return JAVA_LANG_SHORT_TYPE;
607 case T_JavaLangVoid : return JAVA_LANG_VOID_TYPE;
608 case T_JavaLangClass : return JAVA_LANG_CLASS_TYPE;
609 case T_JavaLangClassNotFoundException : return JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE;
610 case T_JavaLangNoClassDefError : return JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE;
611 case T_JavaLangObject : return JAVA_LANG_OBJECT_TYPE;
612 case T_JavaLangString : return JAVA_LANG_STRING_TYPE;
613 case T_JavaLangStringBuffer : return JAVA_LANG_STRINGBUFFER_TYPE;
614 case T_JavaLangSystem : return JAVA_LANG_SYSTEM_TYPE;
615 case T_JavaLangThrowable : return JAVA_LANG_THROWABLE_TYPE;
616 case T_JavaLangError : return JAVA_LANG_ERROR_TYPE;
617 case T_JavaLangException : return JAVA_LANG_EXCEPTION_TYPE;
618 case T_JavaLangReflectConstructor : return JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE;
619 case T_JavaLangAssertionError : return JAVA_LANG_ASSERTIONERROR_TYPE;
623 public int literalIndex(byte[] utf8encoding, char[] stringCharArray) {
625 if ((index = UTF8Cache.get(stringCharArray)) < 0) {
626 // The entry doesn't exit yet
627 index = UTF8Cache.put(stringCharArray, currentIndex);
629 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
632 // Write the tag first
634 // Then the size of the stringName array
635 //writeU2(utf8Constant.length);
636 int savedCurrentOffset = currentOffset;
637 if (currentOffset + 2 >= poolContent.length) {
638 // we need to resize the poolContent array because we won't have
639 // enough space to write the length
640 int length = poolContent.length;
641 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
644 // add in once the whole byte array
645 int length = poolContent.length;
646 int utf8encodingLength = utf8encoding.length;
647 if (currentOffset + utf8encodingLength >= length) {
648 System.arraycopy(poolContent, 0, (poolContent = new byte[length + utf8encodingLength + CONSTANTPOOL_GROW_SIZE]), 0, length);
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 char[] stringName
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 int length = poolContent.length;
677 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
681 for (int i = 0; i < utf8Constant.length; i++) {
682 char current = utf8Constant[i];
683 if ((current >= 0x0001) && (current <= 0x007F)) {
684 // we only need one byte: ASCII table
688 if (current > 0x07FF) {
691 writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
692 writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
693 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
695 // we can be 0 or between 0x0080 and 0x07FF
696 // In that case we only need 2 bytes
698 writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
699 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
702 if (length >= 65535) {
703 currentOffset = savedCurrentOffset - 1;
706 index = UTF8Cache.put(utf8Constant, currentIndex);
708 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
711 // Now we know the length that we have to write in the constant pool
712 // we use savedCurrentOffset to do that
713 poolContent[savedCurrentOffset] = (byte) (length >> 8);
714 poolContent[savedCurrentOffset + 1] = (byte) length;
718 public int literalIndex(char[] stringCharArray, byte[] utf8encoding) {
721 if ((index = stringCache.get(stringCharArray)) < 0) {
722 // The entry doesn't exit yet
723 stringIndex = literalIndex(utf8encoding, stringCharArray);
724 index = stringCache.put(stringCharArray, currentIndex++);
726 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
728 // Write the tag first
730 // Then the string index
731 writeU2(stringIndex);
736 * This method returns the index into the constantPool corresponding to the double
737 * value. If the double is not already present into the pool, it is added. The
738 * double cache is updated and it returns the right index.
740 * @param <CODE>double</CODE> key
741 * @return <CODE>int</CODE>
743 public int literalIndex(double key) {
744 //Retrieve the index from the cache
745 // The double constant takes two indexes into the constant pool, but we only store
746 // the first index into the long table
748 // lazy initialization for base type caches
749 // If it is null, initialize it, otherwise use it
750 if (doubleCache == null) {
751 doubleCache = new DoubleCache(DOUBLE_INITIAL_SIZE);
753 if ((index = doubleCache.get(key)) < 0) {
754 index = doubleCache.put(key, currentIndex++);
756 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
758 currentIndex++; // a double needs an extra place into the constant pool
759 // Write the double into the constant pool
762 // Then add the 8 bytes representing the double
763 long temp = java.lang.Double.doubleToLongBits(key);
764 for (int i = 0; i < 8; i++) {
766 poolContent[currentOffset++] = (byte) (temp >>> (56 - (i << 3)));
767 } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
768 int length = poolContent.length;
769 System.arraycopy(poolContent, 0, (poolContent = new byte[(length << 1) + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
770 poolContent[currentOffset - 1] = (byte) (temp >>> (56 - (i << 3)));
777 * This method returns the index into the constantPool corresponding to the float
778 * value. If the float is not already present into the pool, it is added. The
779 * int cache is updated and it returns the right index.
781 * @param <CODE>float</CODE> key
782 * @return <CODE>int</CODE>
784 public int literalIndex(float key) {
785 //Retrieve the index from the cache
787 // lazy initialization for base type caches
788 // If it is null, initialize it, otherwise use it
789 if (floatCache == null) {
790 floatCache = new FloatCache(FLOAT_INITIAL_SIZE);
792 if ((index = floatCache.get(key)) < 0) {
793 index = floatCache.put(key, currentIndex++);
795 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
797 // Write the float constant entry into the constant pool
800 // Then add the 4 bytes representing the float
801 int temp = java.lang.Float.floatToIntBits(key);
802 for (int i = 0; i < 4; i++) {
804 poolContent[currentOffset++] = (byte) (temp >>> (24 - i * 8));
805 } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
806 int length = poolContent.length;
807 System.arraycopy(poolContent, 0, (poolContent = new byte[length * 2 + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
808 poolContent[currentOffset - 1] = (byte) (temp >>> (24 - i * 8));
815 * This method returns the index into the constantPool corresponding to the int
816 * value. If the int is not already present into the pool, it is added. The
817 * int cache is updated and it returns the right index.
819 * @param <CODE>int</CODE> key
820 * @return <CODE>int</CODE>
822 public int literalIndex(int key) {
823 //Retrieve the index from the cache
825 // lazy initialization for base type caches
826 // If it is null, initialize it, otherwise use it
827 if (intCache == null) {
828 intCache = new IntegerCache(INT_INITIAL_SIZE);
830 if ((index = intCache.get(key)) < 0) {
831 index = intCache.put(key, currentIndex++);
833 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
835 // Write the integer constant entry into the constant pool
838 // Then add the 4 bytes representing the int
839 for (int i = 0; i < 4; i++) {
841 poolContent[currentOffset++] = (byte) (key >>> (24 - i * 8));
842 } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
843 int length = poolContent.length;
844 System.arraycopy(poolContent, 0, (poolContent = new byte[length * 2 + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
845 poolContent[currentOffset - 1] = (byte) (key >>> (24 - i * 8));
852 * This method returns the index into the constantPool corresponding to the long
853 * value. If the long is not already present into the pool, it is added. The
854 * long cache is updated and it returns the right index.
856 * @param <CODE>long</CODE> key
857 * @return <CODE>int</CODE>
859 public int literalIndex(long key) {
860 // Retrieve the index from the cache
861 // The long constant takes two indexes into the constant pool, but we only store
862 // the first index into the long table
864 // lazy initialization for base type caches
865 // If it is null, initialize it, otherwise use it
866 if (longCache == null) {
867 longCache = new LongCache(LONG_INITIAL_SIZE);
869 if ((index = longCache.get(key)) < 0) {
870 index = longCache.put(key, currentIndex++);
872 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
874 currentIndex++; // long value need an extra place into thwe constant pool
875 // Write the long into the constant pool
878 // Then add the 8 bytes representing the long
879 for (int i = 0; i < 8; i++) {
881 poolContent[currentOffset++] = (byte) (key >>> (56 - (i << 3)));
882 } catch (IndexOutOfBoundsException e) { //currentOffset has been ++ already (see the -1)
883 int length = poolContent.length;
884 System.arraycopy(poolContent, 0, (poolContent = new byte[(length << 1) + CONSTANTPOOL_INITIAL_SIZE]), 0, length);
885 poolContent[currentOffset - 1] = (byte) (key >>> (56 - (i << 3)));
892 * This method returns the index into the constantPool corresponding to the type descriptor.
894 * @param stringConstant java.lang.String
895 * @return <CODE>int</CODE>
897 public int literalIndex(String stringConstant) {
899 char[] stringCharArray = stringConstant.toCharArray();
900 if ((index = stringCache.get(stringCharArray)) < 0) {
901 // The entry doesn't exit yet
902 int stringIndex = literalIndex(stringCharArray);
903 index = stringCache.put(stringCharArray, currentIndex++);
905 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
907 // Write the tag first
909 // Then the string index
910 writeU2(stringIndex);
915 * This method returns the index into the constantPool
916 * corresponding to the field binding aFieldBinding.
918 * @param FieldBinding aFieldBinding
919 * @return <CODE>int</CODE>
921 public int literalIndex(FieldBinding aFieldBinding) {
923 int nameAndTypeIndex;
925 int indexWellKnownField;
926 if ((indexWellKnownField = indexOfWellKnownFields(aFieldBinding)) == -1) {
927 if ((index = fieldCache.get(aFieldBinding)) < 0) {
928 // The entry doesn't exit yet
929 classIndex = literalIndex(aFieldBinding.declaringClass);
930 nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
931 index = fieldCache.put(aFieldBinding, currentIndex++);
933 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
935 writeU1(FieldRefTag);
937 writeU2(nameAndTypeIndex);
940 if ((index = wellKnownFields[indexWellKnownField]) == 0) {
941 // that field need to be inserted
942 classIndex = literalIndex(aFieldBinding.declaringClass);
943 nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
944 index = wellKnownFields[indexWellKnownField] = currentIndex++;
946 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
948 writeU1(FieldRefTag);
950 writeU2(nameAndTypeIndex);
956 * This method returns the index into the constantPool corresponding to the
957 * method descriptor. It can be either an interface method reference constant
958 * or a method reference constant.
960 * @param MethodBinding aMethodBinding
961 * @return <CODE>int</CODE>
963 public int literalIndex(MethodBinding aMethodBinding) {
965 int nameAndTypeIndex;
967 int indexWellKnownMethod;
968 if ((indexWellKnownMethod = indexOfWellKnownMethods(aMethodBinding)) == -1) {
969 if (aMethodBinding.declaringClass.isInterface()) {
970 // Lookinf into the interface method ref table
971 if ((index = interfaceMethodCache.get(aMethodBinding)) < 0) {
972 classIndex = literalIndex(aMethodBinding.declaringClass);
973 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
974 index = interfaceMethodCache.put(aMethodBinding, currentIndex++);
976 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
978 // Write the interface method ref constant into the constant pool
980 writeU1(InterfaceMethodRefTag);
981 // Then write the class index
983 // The write the nameAndType index
984 writeU2(nameAndTypeIndex);
987 // Lookinf into the method ref table
988 if ((index = methodCache.get(aMethodBinding)) < 0) {
989 classIndex = literalIndex(aMethodBinding.declaringClass);
990 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
991 index = methodCache.put(aMethodBinding, currentIndex++);
993 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
995 // Write the method ref constant into the constant pool
997 writeU1(MethodRefTag);
998 // Then write the class index
1000 // The write the nameAndType index
1001 writeU2(nameAndTypeIndex);
1005 // This is a well known method
1006 if ((index = wellKnownMethods[indexWellKnownMethod]) == 0) {
1007 // this methods was not inserted yet
1008 if (aMethodBinding.declaringClass.isInterface()) {
1009 // Lookinf into the interface method ref table
1010 classIndex = literalIndex(aMethodBinding.declaringClass);
1011 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
1012 index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
1013 if (index > 0xFFFF){
1014 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1016 // Write the interface method ref constant into the constant pool
1017 // First add the tag
1018 writeU1(InterfaceMethodRefTag);
1019 // Then write the class index
1020 writeU2(classIndex);
1021 // The write the nameAndType index
1022 writeU2(nameAndTypeIndex);
1024 // Lookinf into the method ref table
1025 classIndex = literalIndex(aMethodBinding.declaringClass);
1026 nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
1027 index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
1028 if (index > 0xFFFF){
1029 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1031 // Write the method ref constant into the constant pool
1032 // First add the tag
1033 writeU1(MethodRefTag);
1034 // Then write the class index
1035 writeU2(classIndex);
1036 // The write the nameAndType index
1037 writeU2(nameAndTypeIndex);
1044 * This method returns the index into the constantPool corresponding to the type descriptor.
1046 * @param TypeBinding aTypeBinding
1047 * @return <CODE>int</CODE>
1049 public int literalIndex(TypeBinding aTypeBinding) {
1052 int indexWellKnownType;
1053 if ((indexWellKnownType = indexOfWellKnownTypes(aTypeBinding)) == -1) {
1054 if ((index = classCache.get(aTypeBinding)) < 0) {
1055 // The entry doesn't exit yet
1056 nameIndex = literalIndex(aTypeBinding.constantPoolName());
1057 index = classCache.put(aTypeBinding, currentIndex++);
1058 if (index > 0xFFFF){
1059 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1062 // Then add the 8 bytes representing the long
1066 if ((index = wellKnownTypes[indexWellKnownType]) == 0) {
1067 // Need to insert that binding
1068 nameIndex = literalIndex(aTypeBinding.constantPoolName());
1069 index = wellKnownTypes[indexWellKnownType] = currentIndex++;
1070 if (index > 0xFFFF){
1071 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1074 // Then add the 8 bytes representing the long
1081 * This method returns the index into the constantPool corresponding
1082 * nameAndType constant with nameIndex, typeIndex.
1084 * @param int nameIndex
1085 * @param int nameIndex
1086 * @param org.eclipse.jdt.internal.compiler.lookup.FieldBinding a FieldBinding
1087 * @return <CODE>int</CODE>
1089 public int literalIndexForFields(int nameIndex, int typeIndex, FieldBinding key) {
1091 int indexOfWellKnownFieldNameAndType;
1092 if ((indexOfWellKnownFieldNameAndType = indexOfWellKnownFieldNameAndType(key)) == -1) {
1093 // check if the entry already exists
1094 if ((index = nameAndTypeCacheForFields.get(key)) == -1) {
1095 // The entry doesn't exit yet
1096 index = nameAndTypeCacheForFields.put(key, currentIndex++);
1097 if (index > 0xFFFF){
1098 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1100 writeU1(NameAndTypeTag);
1105 if ((index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType]) == 0) {
1106 index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType] = currentIndex++;
1107 if (index > 0xFFFF){
1108 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1110 writeU1(NameAndTypeTag);
1118 * This method returns the index into the constantPool corresponding to the type descriptor.
1120 * @param TypeBinding aTypeBinding
1121 * @return <CODE>int</CODE>
1123 public int literalIndexForJavaLangBoolean() {
1125 if ((index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE]) == 0) {
1127 // The entry doesn't exit yet
1128 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangBooleanConstantPoolName);
1129 index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE] = currentIndex++;
1130 if (index > 0xFFFF){
1131 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1134 // Then add the 8 bytes representing the long
1140 * This method returns the index into the constantPool
1141 * corresponding to the field binding aFieldBinding.
1143 * @return <CODE>int</CODE>
1145 public int literalIndexForJavaLangBooleanTYPE() {
1147 if ((index = wellKnownFields[TYPE_BOOLEAN_FIELD]) == 0) {
1148 int nameAndTypeIndex;
1150 // The entry doesn't exit yet
1151 classIndex = literalIndexForJavaLangBoolean();
1152 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1153 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1154 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1155 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1156 writeU1(NameAndTypeTag);
1160 index = wellKnownFields[TYPE_BOOLEAN_FIELD] = currentIndex++;
1161 if (index > 0xFFFF){
1162 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1164 writeU1(FieldRefTag);
1165 writeU2(classIndex);
1166 writeU2(nameAndTypeIndex);
1171 * This method returns the index into the constantPool corresponding to the type descriptor.
1173 * @param TypeBinding aTypeBinding
1174 * @return <CODE>int</CODE>
1176 public int literalIndexForJavaLangByte() {
1178 if ((index = wellKnownTypes[JAVA_LANG_BYTE_TYPE]) == 0) {
1180 // The entry doesn't exit yet
1181 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangByteConstantPoolName);
1182 index = wellKnownTypes[JAVA_LANG_BYTE_TYPE] = currentIndex++;
1183 if (index > 0xFFFF){
1184 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1187 // Then add the 8 bytes representing the long
1193 * This method returns the index into the constantPool
1194 * corresponding to the field binding aFieldBinding.
1196 * @return <CODE>int</CODE>
1198 public int literalIndexForJavaLangByteTYPE() {
1200 if ((index = wellKnownFields[TYPE_BYTE_FIELD]) == 0) {
1201 int nameAndTypeIndex;
1203 // The entry doesn't exit yet
1204 classIndex = literalIndexForJavaLangByte();
1205 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1206 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1207 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1208 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1209 writeU1(NameAndTypeTag);
1213 index = wellKnownFields[TYPE_BYTE_FIELD] = currentIndex++;
1214 if (index > 0xFFFF){
1215 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1217 writeU1(FieldRefTag);
1218 writeU2(classIndex);
1219 writeU2(nameAndTypeIndex);
1224 * This method returns the index into the constantPool corresponding to the type descriptor.
1226 * @param TypeBinding aTypeBinding
1227 * @return <CODE>int</CODE>
1229 public int literalIndexForJavaLangCharacter() {
1231 if ((index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE]) == 0) {
1233 // The entry doesn't exit yet
1234 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangCharacterConstantPoolName);
1235 index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE] = currentIndex++;
1236 if (index > 0xFFFF){
1237 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1240 // Then add the 8 bytes representing the long
1246 * This method returns the index into the constantPool
1247 * corresponding to the field binding aFieldBinding.
1249 * @return <CODE>int</CODE>
1251 public int literalIndexForJavaLangCharacterTYPE() {
1253 if ((index = wellKnownFields[TYPE_CHARACTER_FIELD]) == 0) {
1254 int nameAndTypeIndex;
1256 // The entry doesn't exit yet
1257 classIndex = literalIndexForJavaLangCharacter();
1258 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1259 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1260 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1261 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1262 writeU1(NameAndTypeTag);
1266 index = wellKnownFields[TYPE_CHARACTER_FIELD] = currentIndex++;
1267 if (index > 0xFFFF){
1268 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1270 writeU1(FieldRefTag);
1271 writeU2(classIndex);
1272 writeU2(nameAndTypeIndex);
1277 * This method returns the index into the constantPool corresponding to the type descriptor.
1279 * @param TypeBinding aTypeBinding
1280 * @return <CODE>int</CODE>
1282 public int literalIndexForJavaLangClass() {
1284 if ((index = wellKnownTypes[JAVA_LANG_CLASS_TYPE]) == 0) {
1286 // The entry doesn't exit yet
1287 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassConstantPoolName);
1288 index = wellKnownTypes[JAVA_LANG_CLASS_TYPE] = currentIndex++;
1289 if (index > 0xFFFF){
1290 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1293 // Then add the 8 bytes representing the long
1299 * This method returns the index into the constantPool corresponding to the
1300 * method descriptor. It can be either an interface method reference constant
1301 * or a method reference constant.
1303 * @return <CODE>int</CODE>
1305 public int literalIndexForJavaLangClassForName() {
1307 int nameAndTypeIndex;
1309 // Looking into the method ref table
1310 if ((index = wellKnownMethods[FORNAME_CLASS_METHOD]) == 0) {
1311 classIndex = literalIndexForJavaLangClass();
1312 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE]) == 0) {
1313 int nameIndex = literalIndex(QualifiedNamesConstants.ForName);
1314 int typeIndex = literalIndex(QualifiedNamesConstants.ForNameSignature);
1315 nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE] = currentIndex++;
1316 writeU1(NameAndTypeTag);
1320 index = wellKnownMethods[FORNAME_CLASS_METHOD] = currentIndex++;
1321 if (index > 0xFFFF){
1322 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1324 // Write the method ref constant into the constant pool
1325 // First add the tag
1326 writeU1(MethodRefTag);
1327 // Then write the class index
1328 writeU2(classIndex);
1329 // The write the nameAndType index
1330 writeU2(nameAndTypeIndex);
1335 * This method returns the index into the constantPool corresponding to the
1336 * method descriptor. It can be either an interface method reference constant
1337 * or a method reference constant.
1339 * @return <CODE>int</CODE>
1341 public int literalIndexForJavaLangClassGetConstructor() {
1343 int nameAndTypeIndex;
1345 // Looking into the method ref table
1346 if ((index = wellKnownMethods[GETCONSTRUCTOR_CLASS_METHOD]) == 0) {
1347 classIndex = literalIndexForJavaLangClass();
1348 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCONSTRUCTOR_METHOD_NAME_AND_TYPE]) == 0) {
1349 int nameIndex = literalIndex(QualifiedNamesConstants.GetConstructor);
1350 int typeIndex = literalIndex(QualifiedNamesConstants.GetConstructorSignature);
1351 nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCONSTRUCTOR_METHOD_NAME_AND_TYPE] = currentIndex++;
1352 writeU1(NameAndTypeTag);
1356 index = wellKnownMethods[GETCONSTRUCTOR_CLASS_METHOD] = currentIndex++;
1357 if (index > 0xFFFF){
1358 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1360 // Write the method ref constant into the constant pool
1361 // First add the tag
1362 writeU1(MethodRefTag);
1363 // Then write the class index
1364 writeU2(classIndex);
1365 // The write the nameAndType index
1366 writeU2(nameAndTypeIndex);
1371 * This method returns the index into the constantPool corresponding to the
1372 * method descriptor. It can be either an interface method reference constant
1373 * or a method reference constant.
1375 * @return <CODE>int</CODE>
1377 public int literalIndexForJavaLangClassDesiredAssertionStatus() {
1379 int nameAndTypeIndex;
1381 // Looking into the method ref table
1382 if ((index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD]) == 0) {
1383 classIndex = literalIndexForJavaLangClass();
1384 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE]) == 0) {
1385 int nameIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatus);
1386 int typeIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatusSignature);
1387 nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE] = currentIndex++;
1388 writeU1(NameAndTypeTag);
1392 index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD] = currentIndex++;
1393 if (index > 0xFFFF){
1394 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1396 // Write the method ref constant into the constant pool
1397 // First add the tag
1398 writeU1(MethodRefTag);
1399 // Then write the class index
1400 writeU2(classIndex);
1401 // The write the nameAndType index
1402 writeU2(nameAndTypeIndex);
1407 * This method returns the index into the constantPool corresponding to the type descriptor.
1409 * @param TypeBinding aTypeBinding
1410 * @return <CODE>int</CODE>
1412 public int literalIndexForJavaLangClassNotFoundException() {
1414 if ((index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE]) == 0) {
1416 // The entry doesn't exit yet
1417 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassNotFoundExceptionConstantPoolName);
1418 index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE] = currentIndex++;
1419 if (index > 0xFFFF){
1420 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1423 // Then add the 8 bytes representing the long
1429 * This method returns the index into the constantPool corresponding to the type descriptor.
1431 * @param TypeBinding aTypeBinding
1432 * @return <CODE>int</CODE>
1434 public int literalIndexForJavaLangDouble() {
1436 if ((index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE]) == 0) {
1438 // The entry doesn't exit yet
1439 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangDoubleConstantPoolName);
1440 index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE] = currentIndex++;
1441 if (index > 0xFFFF){
1442 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1445 // Then add the 8 bytes representing the long
1451 * This method returns the index into the constantPool
1452 * corresponding to the field binding aFieldBinding.
1454 * @return <CODE>int</CODE>
1456 public int literalIndexForJavaLangDoubleTYPE() {
1458 if ((index = wellKnownFields[TYPE_DOUBLE_FIELD]) == 0) {
1459 int nameAndTypeIndex;
1461 // The entry doesn't exit yet
1462 classIndex = literalIndexForJavaLangDouble();
1463 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1464 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1465 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1466 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1467 writeU1(NameAndTypeTag);
1471 index = wellKnownFields[TYPE_DOUBLE_FIELD] = currentIndex++;
1472 if (index > 0xFFFF){
1473 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1475 writeU1(FieldRefTag);
1476 writeU2(classIndex);
1477 writeU2(nameAndTypeIndex);
1482 * This method returns the index into the constantPool corresponding to the type descriptor.
1484 * @param TypeBinding aTypeBinding
1485 * @return <CODE>int</CODE>
1487 public int literalIndexForJavaLangError() {
1489 if ((index = wellKnownTypes[JAVA_LANG_ERROR_TYPE]) == 0) {
1491 // The entry doesn't exit yet
1492 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangErrorConstantPoolName);
1493 index = wellKnownTypes[JAVA_LANG_ERROR_TYPE] = currentIndex++;
1494 if (index > 0xFFFF){
1495 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1498 // Then add the 8 bytes representing the long
1504 * This method returns the index into the constantPool corresponding to the
1505 * method descriptor. It can be either an interface method reference constant
1506 * or a method reference constant.
1508 * @return <CODE>int</CODE>
1510 public int literalIndexForJavaLangErrorConstructor() {
1512 int nameAndTypeIndex;
1514 // Looking into the method ref table
1515 if ((index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD]) == 0) {
1516 classIndex = literalIndexForJavaLangError();
1517 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
1518 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1519 int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
1520 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
1521 writeU1(NameAndTypeTag);
1525 index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD] = currentIndex++;
1526 if (index > 0xFFFF){
1527 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1529 // Write the method ref constant into the constant pool
1530 // First add the tag
1531 writeU1(MethodRefTag);
1532 // Then write the class index
1533 writeU2(classIndex);
1534 // The write the nameAndType index
1535 writeU2(nameAndTypeIndex);
1539 public int literalIndexForJavaLangException() {
1541 if ((index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE]) == 0) {
1542 // The entry doesn't exit yet
1543 int nameIndex = literalIndex(QualifiedNamesConstants.JavaLangExceptionConstantPoolName);
1544 index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE] = currentIndex++;
1545 if (index > 0xFFFF){
1546 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1549 // Then add the 8 bytes representing the long
1555 * This method returns the index into the constantPool corresponding to the type descriptor.
1557 * @param TypeBinding aTypeBinding
1558 * @return <CODE>int</CODE>
1560 public int literalIndexForJavaLangFloat() {
1562 if ((index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE]) == 0) {
1564 // The entry doesn't exit yet
1565 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangFloatConstantPoolName);
1566 index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE] = currentIndex++;
1567 if (index > 0xFFFF){
1568 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1571 // Then add the 8 bytes representing the long
1577 * This method returns the index into the constantPool
1578 * corresponding to the field binding aFieldBinding.
1580 * @return <CODE>int</CODE>
1582 public int literalIndexForJavaLangFloatTYPE() {
1584 if ((index = wellKnownFields[TYPE_FLOAT_FIELD]) == 0) {
1585 int nameAndTypeIndex;
1587 // The entry doesn't exit yet
1588 classIndex = literalIndexForJavaLangFloat();
1589 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1590 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1591 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1592 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1593 writeU1(NameAndTypeTag);
1597 index = wellKnownFields[TYPE_FLOAT_FIELD] = currentIndex++;
1598 if (index > 0xFFFF){
1599 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1601 writeU1(FieldRefTag);
1602 writeU2(classIndex);
1603 writeU2(nameAndTypeIndex);
1608 * This method returns the index into the constantPool corresponding to the type descriptor.
1610 * @param TypeBinding aTypeBinding
1611 * @return <CODE>int</CODE>
1613 public int literalIndexForJavaLangInteger() {
1615 if ((index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE]) == 0) {
1617 // The entry doesn't exit yet
1618 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangIntegerConstantPoolName);
1619 index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE] = currentIndex++;
1620 if (index > 0xFFFF){
1621 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1624 // Then add the 8 bytes representing the long
1630 * This method returns the index into the constantPool
1631 * corresponding to the field binding aFieldBinding.
1633 * @return <CODE>int</CODE>
1635 public int literalIndexForJavaLangIntegerTYPE() {
1637 if ((index = wellKnownFields[TYPE_INTEGER_FIELD]) == 0) {
1638 int nameAndTypeIndex;
1640 // The entry doesn't exit yet
1641 classIndex = literalIndexForJavaLangInteger();
1642 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1643 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1644 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1645 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1646 writeU1(NameAndTypeTag);
1650 index = wellKnownFields[TYPE_INTEGER_FIELD] = currentIndex++;
1651 if (index > 0xFFFF){
1652 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1654 writeU1(FieldRefTag);
1655 writeU2(classIndex);
1656 writeU2(nameAndTypeIndex);
1661 * This method returns the index into the constantPool corresponding to the type descriptor.
1663 * @param TypeBinding aTypeBinding
1664 * @return <CODE>int</CODE>
1666 public int literalIndexForJavaLangLong() {
1668 if ((index = wellKnownTypes[JAVA_LANG_LONG_TYPE]) == 0) {
1670 // The entry doesn't exit yet
1671 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangLongConstantPoolName);
1672 index = wellKnownTypes[JAVA_LANG_LONG_TYPE] = currentIndex++;
1673 if (index > 0xFFFF){
1674 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1677 // Then add the 8 bytes representing the long
1683 * This method returns the index into the constantPool
1684 * corresponding to the field binding aFieldBinding.
1686 * @return <CODE>int</CODE>
1688 public int literalIndexForJavaLangLongTYPE() {
1690 if ((index = wellKnownFields[TYPE_LONG_FIELD]) == 0) {
1691 int nameAndTypeIndex;
1693 // The entry doesn't exit yet
1694 classIndex = literalIndexForJavaLangLong();
1695 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
1696 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
1697 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
1698 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
1699 writeU1(NameAndTypeTag);
1703 index = wellKnownFields[TYPE_LONG_FIELD] = currentIndex++;
1704 if (index > 0xFFFF){
1705 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1707 writeU1(FieldRefTag);
1708 writeU2(classIndex);
1709 writeU2(nameAndTypeIndex);
1714 * This method returns the index into the constantPool corresponding to the type descriptor.
1716 * @param TypeBinding aTypeBinding
1717 * @return <CODE>int</CODE>
1719 public int literalIndexForJavaLangNoClassDefFoundError() {
1721 if ((index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE]) == 0) {
1723 // The entry doesn't exit yet
1724 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangNoClassDefFoundErrorConstantPoolName);
1725 index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_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 TypeBinding aTypeBinding
1740 * @return <CODE>int</CODE>
1742 public int literalIndexForJavaLangAssertionError() {
1744 if ((index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE]) == 0) {
1746 // The entry doesn't exit yet
1747 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangAssertionErrorConstantPoolName);
1748 index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE] = currentIndex++;
1749 if (index > 0xFFFF){
1750 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1753 // Then add the 8 bytes representing the long
1760 * This method returns the index into the constantPool corresponding to the type descriptor.
1762 * @param TypeBinding aTypeBinding
1763 * @return <CODE>int</CODE>
1765 public int literalIndexForJavaLangAssertionErrorConstructor(int typeBindingID) {
1767 int nameAndTypeIndex = 0;
1769 switch (typeBindingID) {
1773 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD]) == 0) {
1774 classIndex = literalIndexForJavaLangAssertionError();
1775 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE]) == 0) {
1776 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1777 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorIntConstrSignature);
1778 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
1779 writeU1(NameAndTypeTag);
1783 index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD] = currentIndex++;
1784 if (index > 0xFFFF){
1785 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1787 // Write the method ref constant into the constant pool
1788 // First add the tag
1789 writeU1(MethodRefTag);
1790 // Then write the class index
1791 writeU2(classIndex);
1792 // The write the nameAndType index
1793 writeU2(nameAndTypeIndex);
1797 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD]) == 0) {
1798 classIndex = literalIndexForJavaLangAssertionError();
1799 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE]) == 0) {
1800 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1801 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorLongConstrSignature);
1802 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
1803 writeU1(NameAndTypeTag);
1807 index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD] = currentIndex++;
1808 if (index > 0xFFFF){
1809 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1811 // Write the method ref constant into the constant pool
1812 // First add the tag
1813 writeU1(MethodRefTag);
1814 // Then write the class index
1815 writeU2(classIndex);
1816 // The write the nameAndType index
1817 writeU2(nameAndTypeIndex);
1821 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD]) == 0) {
1822 classIndex = literalIndexForJavaLangAssertionError();
1823 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
1824 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1825 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorFloatConstrSignature);
1826 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
1827 writeU1(NameAndTypeTag);
1831 index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD] = currentIndex++;
1832 if (index > 0xFFFF){
1833 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1835 // Write the method ref constant into the constant pool
1836 // First add the tag
1837 writeU1(MethodRefTag);
1838 // Then write the class index
1839 writeU2(classIndex);
1840 // The write the nameAndType index
1841 writeU2(nameAndTypeIndex);
1845 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD]) == 0) {
1846 classIndex = literalIndexForJavaLangAssertionError();
1847 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
1848 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1849 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorDoubleConstrSignature);
1850 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
1851 writeU1(NameAndTypeTag);
1855 index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD] = currentIndex++;
1856 if (index > 0xFFFF){
1857 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1859 // Write the method ref constant into the constant pool
1860 // First add the tag
1861 writeU1(MethodRefTag);
1862 // Then write the class index
1863 writeU2(classIndex);
1864 // The write the nameAndType index
1865 writeU2(nameAndTypeIndex);
1869 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD]) == 0) {
1870 classIndex = literalIndexForJavaLangAssertionError();
1871 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
1872 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1873 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorCharConstrSignature);
1874 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
1875 writeU1(NameAndTypeTag);
1879 index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD] = currentIndex++;
1880 if (index > 0xFFFF){
1881 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1883 // Write the method ref constant into the constant pool
1884 // First add the tag
1885 writeU1(MethodRefTag);
1886 // Then write the class index
1887 writeU2(classIndex);
1888 // The write the nameAndType index
1889 writeU2(nameAndTypeIndex);
1893 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD]) == 0) {
1894 classIndex = literalIndexForJavaLangAssertionError();
1895 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
1896 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1897 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorBooleanConstrSignature);
1898 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
1899 writeU1(NameAndTypeTag);
1903 index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD] = currentIndex++;
1904 if (index > 0xFFFF){
1905 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1907 // Write the method ref constant into the constant pool
1908 // First add the tag
1909 writeU1(MethodRefTag);
1910 // Then write the class index
1911 writeU2(classIndex);
1912 // The write the nameAndType index
1913 writeU2(nameAndTypeIndex);
1920 if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD]) == 0) {
1921 classIndex = literalIndexForJavaLangAssertionError();
1922 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
1923 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1924 int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorObjectConstrSignature);
1925 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
1926 writeU1(NameAndTypeTag);
1930 index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD] = currentIndex++;
1931 if (index > 0xFFFF){
1932 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1934 // Write the method ref constant into the constant pool
1935 // First add the tag
1936 writeU1(MethodRefTag);
1937 // Then write the class index
1938 writeU2(classIndex);
1939 // The write the nameAndType index
1940 writeU2(nameAndTypeIndex);
1947 * This method returns the index into the constantPool corresponding to the
1948 * method descriptor. It can be either an interface method reference constant
1949 * or a method reference constant.
1951 * @return <CODE>int</CODE>
1953 public int literalIndexForJavaLangAssertionErrorDefaultConstructor() {
1955 int nameAndTypeIndex;
1957 // Looking into the method ref table
1958 if ((index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD]) == 0) {
1959 classIndex = literalIndexForJavaLangAssertionError();
1960 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
1961 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
1962 int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
1963 nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
1964 writeU1(NameAndTypeTag);
1968 index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD] = currentIndex++;
1969 if (index > 0xFFFF){
1970 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
1972 // Write the method ref constant into the constant pool
1973 // First add the tag
1974 writeU1(MethodRefTag);
1975 // Then write the class index
1976 writeU2(classIndex);
1977 // The write the nameAndType index
1978 writeU2(nameAndTypeIndex);
1985 * This method returns the index into the constantPool corresponding to the
1986 * method descriptor. It can be either an interface method reference constant
1987 * or a method reference constant.
1989 * @return <CODE>int</CODE>
1991 public int literalIndexForJavaLangNoClassDefFoundErrorStringConstructor() {
1993 int nameAndTypeIndex;
1995 // Looking into the method ref table
1996 if ((index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD]) == 0) {
1997 classIndex = literalIndexForJavaLangNoClassDefFoundError();
1998 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
1999 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2000 int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
2001 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2002 writeU1(NameAndTypeTag);
2006 index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD] = currentIndex++;
2007 if (index > 0xFFFF){
2008 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2010 // Write the method ref constant into the constant pool
2011 // First add the tag
2012 writeU1(MethodRefTag);
2013 // Then write the class index
2014 writeU2(classIndex);
2015 // The write the nameAndType index
2016 writeU2(nameAndTypeIndex);
2021 * This method returns the index into the constantPool corresponding to the type descriptor.
2023 * @param TypeBinding aTypeBinding
2024 * @return <CODE>int</CODE>
2026 public int literalIndexForJavaLangObject() {
2028 if ((index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE]) == 0) {
2030 // The entry doesn't exit yet
2031 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangObjectConstantPoolName);
2032 index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE] = currentIndex++;
2033 if (index > 0xFFFF){
2034 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2037 // Then add the 8 bytes representing the long
2043 * This method returns the index into the constantPool corresponding to the type descriptor.
2045 * @param TypeBinding aTypeBinding
2046 * @return <CODE>int</CODE>
2048 public int literalIndexForJavaLangReflectConstructor() {
2050 if ((index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE]) == 0) {
2052 // The entry doesn't exit yet
2053 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangReflectConstructor);
2054 index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE] = currentIndex++;
2055 if (index > 0xFFFF){
2056 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2059 // Then add the 8 bytes representing the long
2064 public int literalIndexForJavaLangReflectConstructorNewInstance() {
2066 int nameAndTypeIndex;
2068 // Looking into the method ref table
2069 if ((index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD]) == 0) {
2070 classIndex = literalIndexForJavaLangReflectConstructor();
2071 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE]) == 0) {
2072 int nameIndex = literalIndex(QualifiedNamesConstants.NewInstance);
2073 int typeIndex = literalIndex(QualifiedNamesConstants.NewInstanceSignature);
2074 nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE] = currentIndex++;
2075 writeU1(NameAndTypeTag);
2079 index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD] = currentIndex++;
2080 if (index > 0xFFFF){
2081 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2083 // Write the method ref constant into the constant pool
2084 // First add the tag
2085 writeU1(MethodRefTag);
2086 // Then write the class index
2087 writeU2(classIndex);
2088 // The write the nameAndType index
2089 writeU2(nameAndTypeIndex);
2094 * This method returns the index into the constantPool corresponding to the type descriptor.
2096 * @param TypeBinding aTypeBinding
2097 * @return <CODE>int</CODE>
2099 public int literalIndexForJavaLangShort() {
2101 if ((index = wellKnownTypes[JAVA_LANG_SHORT_TYPE]) == 0) {
2103 // The entry doesn't exit yet
2104 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangShortConstantPoolName);
2105 index = wellKnownTypes[JAVA_LANG_SHORT_TYPE] = currentIndex++;
2106 if (index > 0xFFFF){
2107 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2110 // Then add the 8 bytes representing the long
2116 * This method returns the index into the constantPool
2117 * corresponding to the field binding aFieldBinding.
2119 * @return <CODE>int</CODE>
2121 public int literalIndexForJavaLangShortTYPE() {
2123 if ((index = wellKnownFields[TYPE_SHORT_FIELD]) == 0) {
2124 int nameAndTypeIndex;
2126 // The entry doesn't exit yet
2127 classIndex = literalIndexForJavaLangShort();
2128 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
2129 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
2130 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
2131 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
2132 writeU1(NameAndTypeTag);
2136 index = wellKnownFields[TYPE_SHORT_FIELD] = currentIndex++;
2137 if (index > 0xFFFF){
2138 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2140 writeU1(FieldRefTag);
2141 writeU2(classIndex);
2142 writeU2(nameAndTypeIndex);
2147 * This method returns the index into the constantPool corresponding to the type descriptor.
2149 * @param TypeBinding aTypeBinding
2150 * @return <CODE>int</CODE>
2152 public int literalIndexForJavaLangString() {
2154 if ((index = wellKnownTypes[JAVA_LANG_STRING_TYPE]) == 0) {
2156 // The entry doesn't exit yet
2157 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringConstantPoolName);
2158 index = wellKnownTypes[JAVA_LANG_STRING_TYPE] = currentIndex++;
2159 if (index > 0xFFFF){
2160 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2163 // Then add the 8 bytes representing the long
2169 * This method returns the index into the constantPool corresponding to the type descriptor.
2171 * @param TypeBinding aTypeBinding
2172 * @return <CODE>int</CODE>
2174 public int literalIndexForJavaLangStringBuffer() {
2176 if ((index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE]) == 0) {
2178 // The entry doesn't exit yet
2179 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringBufferConstantPoolName);
2180 index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE] = currentIndex++;
2181 if (index > 0xFFFF){
2182 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2185 // Then add the 8 bytes representing the long
2191 * This method returns the index into the constantPool corresponding to the
2192 * method descriptor. It can be either an interface method reference constant
2193 * or a method reference constant.
2195 * @return <CODE>int</CODE>
2197 public int literalIndexForJavaLangStringBufferAppend(int typeID) {
2199 int nameAndTypeIndex = 0;
2205 if ((index = wellKnownMethods[APPEND_INT_METHOD]) == 0) {
2206 classIndex = literalIndexForJavaLangStringBuffer();
2207 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE]) == 0) {
2208 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2209 int typeIndex = literalIndex(QualifiedNamesConstants.AppendIntSignature);
2210 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
2211 writeU1(NameAndTypeTag);
2215 index = wellKnownMethods[APPEND_INT_METHOD] = currentIndex++;
2216 if (index > 0xFFFF){
2217 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2219 // Write the method ref constant into the constant pool
2220 // First add the tag
2221 writeU1(MethodRefTag);
2222 // Then write the class index
2223 writeU2(classIndex);
2224 // The write the nameAndType index
2225 writeU2(nameAndTypeIndex);
2229 if ((index = wellKnownMethods[APPEND_LONG_METHOD]) == 0) {
2230 classIndex = literalIndexForJavaLangStringBuffer();
2231 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE]) == 0) {
2232 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2233 int typeIndex = literalIndex(QualifiedNamesConstants.AppendLongSignature);
2234 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
2235 writeU1(NameAndTypeTag);
2239 index = wellKnownMethods[APPEND_LONG_METHOD] = currentIndex++;
2240 if (index > 0xFFFF){
2241 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2243 // Write the method ref constant into the constant pool
2244 // First add the tag
2245 writeU1(MethodRefTag);
2246 // Then write the class index
2247 writeU2(classIndex);
2248 // The write the nameAndType index
2249 writeU2(nameAndTypeIndex);
2253 if ((index = wellKnownMethods[APPEND_FLOAT_METHOD]) == 0) {
2254 classIndex = literalIndexForJavaLangStringBuffer();
2255 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
2256 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2257 int typeIndex = literalIndex(QualifiedNamesConstants.AppendFloatSignature);
2258 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
2259 writeU1(NameAndTypeTag);
2263 index = wellKnownMethods[APPEND_FLOAT_METHOD] = currentIndex++;
2264 if (index > 0xFFFF){
2265 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2267 // Write the method ref constant into the constant pool
2268 // First add the tag
2269 writeU1(MethodRefTag);
2270 // Then write the class index
2271 writeU2(classIndex);
2272 // The write the nameAndType index
2273 writeU2(nameAndTypeIndex);
2277 if ((index = wellKnownMethods[APPEND_DOUBLE_METHOD]) == 0) {
2278 classIndex = literalIndexForJavaLangStringBuffer();
2279 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
2280 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2281 int typeIndex = literalIndex(QualifiedNamesConstants.AppendDoubleSignature);
2282 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
2283 writeU1(NameAndTypeTag);
2287 index = wellKnownMethods[APPEND_DOUBLE_METHOD] = currentIndex++;
2288 if (index > 0xFFFF){
2289 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2291 // Write the method ref constant into the constant pool
2292 // First add the tag
2293 writeU1(MethodRefTag);
2294 // Then write the class index
2295 writeU2(classIndex);
2296 // The write the nameAndType index
2297 writeU2(nameAndTypeIndex);
2301 if ((index = wellKnownMethods[APPEND_CHAR_METHOD]) == 0) {
2302 classIndex = literalIndexForJavaLangStringBuffer();
2303 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
2304 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2305 int typeIndex = literalIndex(QualifiedNamesConstants.AppendCharSignature);
2306 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
2307 writeU1(NameAndTypeTag);
2311 index = wellKnownMethods[APPEND_CHAR_METHOD] = currentIndex++;
2312 if (index > 0xFFFF){
2313 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2315 // Write the method ref constant into the constant pool
2316 // First add the tag
2317 writeU1(MethodRefTag);
2318 // Then write the class index
2319 writeU2(classIndex);
2320 // The write the nameAndType index
2321 writeU2(nameAndTypeIndex);
2325 if ((index = wellKnownMethods[APPEND_BOOLEAN_METHOD]) == 0) {
2326 classIndex = literalIndexForJavaLangStringBuffer();
2327 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
2328 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2329 int typeIndex = literalIndex(QualifiedNamesConstants.AppendBooleanSignature);
2330 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
2331 writeU1(NameAndTypeTag);
2335 index = wellKnownMethods[APPEND_BOOLEAN_METHOD] = currentIndex++;
2336 if (index > 0xFFFF){
2337 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2339 // Write the method ref constant into the constant pool
2340 // First add the tag
2341 writeU1(MethodRefTag);
2342 // Then write the class index
2343 writeU2(classIndex);
2344 // The write the nameAndType index
2345 writeU2(nameAndTypeIndex);
2349 if ((index = wellKnownMethods[APPEND_OBJECT_METHOD]) == 0) {
2350 classIndex = literalIndexForJavaLangStringBuffer();
2351 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
2352 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2353 int typeIndex = literalIndex(QualifiedNamesConstants.AppendObjectSignature);
2354 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
2355 writeU1(NameAndTypeTag);
2359 index = wellKnownMethods[APPEND_OBJECT_METHOD] = currentIndex++;
2360 if (index > 0xFFFF){
2361 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2363 // Write the method ref constant into the constant pool
2364 // First add the tag
2365 writeU1(MethodRefTag);
2366 // Then write the class index
2367 writeU2(classIndex);
2368 // The write the nameAndType index
2369 writeU2(nameAndTypeIndex);
2374 if ((index = wellKnownMethods[APPEND_STRING_METHOD]) == 0) {
2375 classIndex = literalIndexForJavaLangStringBuffer();
2376 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2377 int nameIndex = literalIndex(QualifiedNamesConstants.Append);
2378 int typeIndex = literalIndex(QualifiedNamesConstants.AppendStringSignature);
2379 nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2380 writeU1(NameAndTypeTag);
2384 index = wellKnownMethods[APPEND_STRING_METHOD] = currentIndex++;
2385 if (index > 0xFFFF){
2386 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2388 // Write the method ref constant into the constant pool
2389 // First add the tag
2390 writeU1(MethodRefTag);
2391 // Then write the class index
2392 writeU2(classIndex);
2393 // The write the nameAndType index
2394 writeU2(nameAndTypeIndex);
2401 * This method returns the index into the constantPool corresponding to the
2402 * method descriptor. It can be either an interface method reference constant
2403 * or a method reference constant.
2405 * @return <CODE>int</CODE>
2407 public int literalIndexForJavaLangStringBufferConstructor() {
2409 int nameAndTypeIndex;
2411 // Looking into the method ref table
2412 if ((index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD]) == 0) {
2413 classIndex = literalIndexForJavaLangStringBuffer();
2414 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
2415 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2416 int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
2417 nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2418 writeU1(NameAndTypeTag);
2422 index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD] = currentIndex++;
2423 if (index > 0xFFFF){
2424 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2426 // Write the method ref constant into the constant pool
2427 // First add the tag
2428 writeU1(MethodRefTag);
2429 // Then write the class index
2430 writeU2(classIndex);
2431 // The write the nameAndType index
2432 writeU2(nameAndTypeIndex);
2437 * This method returns the index into the constantPool corresponding to the
2438 * method descriptor. It can be either an interface method reference constant
2439 * or a method reference constant.
2441 * @return <CODE>int</CODE>
2443 public int literalIndexForJavaLangStringBufferDefaultConstructor() {
2445 int nameAndTypeIndex;
2447 // Looking into the method ref table
2448 if ((index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD]) == 0) {
2449 classIndex = literalIndexForJavaLangStringBuffer();
2450 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
2451 int nameIndex = literalIndex(QualifiedNamesConstants.Init);
2452 int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
2453 nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
2454 writeU1(NameAndTypeTag);
2458 index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD] = currentIndex++;
2459 if (index > 0xFFFF){
2460 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2462 // Write the method ref constant into the constant pool
2463 // First add the tag
2464 writeU1(MethodRefTag);
2465 // Then write the class index
2466 writeU2(classIndex);
2467 // The write the nameAndType index
2468 writeU2(nameAndTypeIndex);
2473 * This method returns the index into the constantPool corresponding to the
2474 * method descriptor. It can be either an interface method reference constant
2475 * or a method reference constant.
2477 * @return <CODE>int</CODE>
2479 public int literalIndexForJavaLangStringBufferToString() {
2481 int nameAndTypeIndex;
2483 // Looking into the method ref table
2484 if ((index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD]) == 0) {
2485 classIndex = literalIndexForJavaLangStringBuffer();
2486 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE]) == 0) {
2487 int nameIndex = literalIndex(QualifiedNamesConstants.ToString);
2488 int typeIndex = literalIndex(QualifiedNamesConstants.ToStringSignature);
2489 nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE] = currentIndex++;
2490 writeU1(NameAndTypeTag);
2494 index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD] = currentIndex++;
2495 if (index > 0xFFFF){
2496 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2498 // Write the method ref constant into the constant pool
2499 // First add the tag
2500 writeU1(MethodRefTag);
2501 // Then write the class index
2502 writeU2(classIndex);
2503 // The write the nameAndType index
2504 writeU2(nameAndTypeIndex);
2509 * This method returns the index into the constantPool corresponding to the
2510 * method descriptor. It can be either an interface method reference constant
2511 * or a method reference constant.
2513 * @return <CODE>int</CODE>
2515 public int literalIndexForJavaLangStringIntern() {
2517 int nameAndTypeIndex;
2519 // Looking into the method ref table
2520 if ((index = wellKnownMethods[STRING_INTERN_METHOD]) == 0) {
2521 classIndex = literalIndexForJavaLangString();
2522 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE]) == 0) {
2523 int nameIndex = literalIndex(QualifiedNamesConstants.Intern);
2524 int typeIndex = literalIndex(QualifiedNamesConstants.InternSignature);
2525 nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE] = currentIndex++;
2526 writeU1(NameAndTypeTag);
2530 index = wellKnownMethods[STRING_INTERN_METHOD] = currentIndex++;
2531 if (index > 0xFFFF){
2532 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2534 // Write the method ref constant into the constant pool
2535 // First add the tag
2536 writeU1(MethodRefTag);
2537 // Then write the class index
2538 writeU2(classIndex);
2539 // The write the nameAndType index
2540 writeU2(nameAndTypeIndex);
2545 * This method returns the index into the constantPool corresponding to the
2546 * method descriptor. It can be either an interface method reference constant
2547 * or a method reference constant.
2549 * @return <CODE>int</CODE>
2551 public int literalIndexForJavaLangStringValueOf(int typeID) {
2553 int nameAndTypeIndex = 0;
2554 int classIndex = literalIndexForJavaLangString();
2559 if ((index = wellKnownMethods[VALUEOF_INT_METHOD]) == 0) {
2560 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE]) == 0) {
2561 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2562 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfIntSignature);
2563 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
2564 writeU1(NameAndTypeTag);
2568 index = wellKnownMethods[VALUEOF_INT_METHOD] = currentIndex++;
2569 if (index > 0xFFFF){
2570 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2572 // Write the method ref constant into the constant pool
2573 // First add the tag
2574 writeU1(MethodRefTag);
2575 // Then write the class index
2576 writeU2(classIndex);
2577 // The write the nameAndType index
2578 writeU2(nameAndTypeIndex);
2582 if ((index = wellKnownMethods[VALUEOF_LONG_METHOD]) == 0) {
2583 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE]) == 0) {
2584 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2585 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfLongSignature);
2586 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
2587 writeU1(NameAndTypeTag);
2591 index = wellKnownMethods[VALUEOF_LONG_METHOD] = currentIndex++;
2592 if (index > 0xFFFF){
2593 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2595 // Write the method ref constant into the constant pool
2596 // First add the tag
2597 writeU1(MethodRefTag);
2598 // Then write the class index
2599 writeU2(classIndex);
2600 // The write the nameAndType index
2601 writeU2(nameAndTypeIndex);
2605 if ((index = wellKnownMethods[VALUEOF_FLOAT_METHOD]) == 0) {
2606 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
2607 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2608 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfFloatSignature);
2609 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
2610 writeU1(NameAndTypeTag);
2614 index = wellKnownMethods[VALUEOF_FLOAT_METHOD] = currentIndex++;
2615 if (index > 0xFFFF){
2616 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2618 // Write the method ref constant into the constant pool
2619 // First add the tag
2620 writeU1(MethodRefTag);
2621 // Then write the class index
2622 writeU2(classIndex);
2623 // The write the nameAndType index
2624 writeU2(nameAndTypeIndex);
2628 if ((index = wellKnownMethods[VALUEOF_DOUBLE_METHOD]) == 0) {
2629 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
2630 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2631 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfDoubleSignature);
2632 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
2633 writeU1(NameAndTypeTag);
2637 index = wellKnownMethods[VALUEOF_DOUBLE_METHOD] = currentIndex++;
2638 if (index > 0xFFFF){
2639 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2641 // Write the method ref constant into the constant pool
2642 // First add the tag
2643 writeU1(MethodRefTag);
2644 // Then write the class index
2645 writeU2(classIndex);
2646 // The write the nameAndType index
2647 writeU2(nameAndTypeIndex);
2651 if ((index = wellKnownMethods[VALUEOF_CHAR_METHOD]) == 0) {
2652 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
2653 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2654 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfCharSignature);
2655 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
2656 writeU1(NameAndTypeTag);
2660 index = wellKnownMethods[VALUEOF_CHAR_METHOD] = currentIndex++;
2661 if (index > 0xFFFF){
2662 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2664 // Write the method ref constant into the constant pool
2665 // First add the tag
2666 writeU1(MethodRefTag);
2667 // Then write the class index
2668 writeU2(classIndex);
2669 // The write the nameAndType index
2670 writeU2(nameAndTypeIndex);
2674 if ((index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD]) == 0) {
2675 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
2676 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2677 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfBooleanSignature);
2678 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
2679 writeU1(NameAndTypeTag);
2683 index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD] = currentIndex++;
2684 if (index > 0xFFFF){
2685 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2687 // Write the method ref constant into the constant pool
2688 // First add the tag
2689 writeU1(MethodRefTag);
2690 // Then write the class index
2691 writeU2(classIndex);
2692 // The write the nameAndType index
2693 writeU2(nameAndTypeIndex);
2697 if ((index = wellKnownMethods[VALUEOF_OBJECT_METHOD]) == 0) {
2698 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
2699 int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
2700 int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfObjectSignature);
2701 nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
2702 writeU1(NameAndTypeTag);
2706 index = wellKnownMethods[VALUEOF_OBJECT_METHOD] = currentIndex++;
2707 if (index > 0xFFFF){
2708 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2710 // Write the method ref constant into the constant pool
2711 // First add the tag
2712 writeU1(MethodRefTag);
2713 // Then write the class index
2714 writeU2(classIndex);
2715 // The write the nameAndType index
2716 writeU2(nameAndTypeIndex);
2723 * This method returns the index into the constantPool corresponding to the type descriptor.
2725 * @param TypeBinding aTypeBinding
2726 * @return <CODE>int</CODE>
2728 public int literalIndexForJavaLangSystem() {
2730 if ((index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE]) == 0) {
2732 // The entry doesn't exit yet
2733 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangSystemConstantPoolName);
2734 index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE] = currentIndex++;
2735 if (index > 0xFFFF){
2736 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2739 // Then add the 8 bytes representing the long
2745 * This method returns the index into the constantPool corresponding to the
2746 * method descriptor. It can be either an interface method reference constant
2747 * or a method reference constant.
2749 * @return <CODE>int</CODE>
2751 public int literalIndexForJavaLangSystemExitInt() {
2753 int nameAndTypeIndex;
2755 // Looking into the method ref table
2756 if ((index = wellKnownMethods[SYSTEM_EXIT_METHOD]) == 0) {
2757 classIndex = literalIndexForJavaLangSystem();
2758 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE]) == 0) {
2759 int nameIndex = literalIndex(QualifiedNamesConstants.Exit);
2760 int typeIndex = literalIndex(QualifiedNamesConstants.ExitIntSignature);
2761 nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE] = currentIndex++;
2762 writeU1(NameAndTypeTag);
2766 index = wellKnownMethods[SYSTEM_EXIT_METHOD] = currentIndex++;
2767 if (index > 0xFFFF){
2768 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2770 // Write the method ref constant into the constant pool
2771 // First add the tag
2772 writeU1(MethodRefTag);
2773 // Then write the class index
2774 writeU2(classIndex);
2775 // The write the nameAndType index
2776 writeU2(nameAndTypeIndex);
2781 * This method returns the index into the constantPool
2782 * corresponding to the field binding aFieldBinding.
2784 * @return <CODE>int</CODE>
2786 public int literalIndexForJavaLangSystemOut() {
2788 if ((index = wellKnownFields[OUT_SYSTEM_FIELD]) == 0) {
2789 int nameAndTypeIndex;
2791 // The entry doesn't exit yet
2792 classIndex = literalIndexForJavaLangSystem();
2793 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE]) == 0) {
2794 int nameIndex = literalIndex(QualifiedNamesConstants.Out);
2795 int typeIndex = literalIndex(QualifiedNamesConstants.JavaIoPrintStreamSignature);
2796 nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE] = currentIndex++;
2797 writeU1(NameAndTypeTag);
2801 index = wellKnownFields[OUT_SYSTEM_FIELD] = currentIndex++;
2802 if (index > 0xFFFF){
2803 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2805 writeU1(FieldRefTag);
2806 writeU2(classIndex);
2807 writeU2(nameAndTypeIndex);
2812 * This method returns the index into the constantPool corresponding to the type descriptor.
2814 * @param TypeBinding aTypeBinding
2815 * @return <CODE>int</CODE>
2817 public int literalIndexForJavaLangThrowable() {
2819 if ((index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE]) == 0) {
2821 // The entry doesn't exit yet
2822 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangThrowableConstantPoolName);
2823 index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE] = currentIndex++;
2824 if (index > 0xFFFF){
2825 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2828 // Then add the 8 bytes representing the long
2834 * This method returns the index into the constantPool corresponding to the
2835 * method descriptor. It can be either an interface method reference constant
2836 * or a method reference constant.
2838 * @return <CODE>int</CODE>
2840 public int literalIndexForJavaLangThrowableGetMessage() {
2842 int nameAndTypeIndex;
2844 // Looking into the method ref table
2845 if ((index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD]) == 0) {
2846 classIndex = literalIndexForJavaLangThrowable();
2847 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE]) == 0) {
2848 int nameIndex = literalIndex(QualifiedNamesConstants.GetMessage);
2849 int typeIndex = literalIndex(QualifiedNamesConstants.GetMessageSignature);
2850 nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE] = currentIndex++;
2851 writeU1(NameAndTypeTag);
2855 index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD] = currentIndex++;
2856 if (index > 0xFFFF){
2857 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2859 // Write the method ref constant into the constant pool
2860 // First add the tag
2861 writeU1(MethodRefTag);
2862 // Then write the class index
2863 writeU2(classIndex);
2864 // The write the nameAndType index
2865 writeU2(nameAndTypeIndex);
2870 * This method returns the index into the constantPool corresponding to the type descriptor.
2872 * @param TypeBinding aTypeBinding
2873 * @return <CODE>int</CODE>
2875 public int literalIndexForJavaLangVoid() {
2877 if ((index = wellKnownTypes[JAVA_LANG_VOID_TYPE]) == 0) {
2879 // The entry doesn't exit yet
2880 nameIndex = literalIndex(QualifiedNamesConstants.JavaLangVoidConstantPoolName);
2881 index = wellKnownTypes[JAVA_LANG_VOID_TYPE] = currentIndex++;
2882 if (index > 0xFFFF){
2883 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2886 // Then add the 8 bytes representing the long
2892 * This method returns the index into the constantPool
2893 * corresponding to the field binding aFieldBinding.
2895 * @return <CODE>int</CODE>
2897 public int literalIndexForJavaLangVoidTYPE() {
2899 if ((index = wellKnownFields[TYPE_VOID_FIELD]) == 0) {
2900 int nameAndTypeIndex;
2902 // The entry doesn't exit yet
2903 classIndex = literalIndexForJavaLangVoid();
2904 if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
2905 int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
2906 int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
2907 nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
2908 writeU1(NameAndTypeTag);
2912 index = wellKnownFields[TYPE_VOID_FIELD] = currentIndex++;
2913 if (index > 0xFFFF){
2914 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2916 writeU1(FieldRefTag);
2917 writeU2(classIndex);
2918 writeU2(nameAndTypeIndex);
2923 * This method returns the index into the constantPool corresponding to the type descriptor.
2925 * @param char[] stringName
2926 * @return <CODE>int</CODE>
2928 public int literalIndexForLdc(char[] stringCharArray) {
2930 if ((index = stringCache.get(stringCharArray)) < 0) {
2932 // The entry doesn't exit yet
2933 if ((stringIndex = UTF8Cache.get(stringCharArray)) < 0) {
2934 // The entry doesn't exit yet
2935 // Write the tag first
2937 // Then the size of the stringName array
2938 int savedCurrentOffset = currentOffset;
2939 if (currentOffset + 2 >= poolContent.length) {
2940 // we need to resize the poolContent array because we won't have
2941 // enough space to write the length
2942 int length = poolContent.length;
2943 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
2947 for (int i = 0; i < stringCharArray.length; i++) {
2948 char current = stringCharArray[i];
2949 if ((current >= 0x0001) && (current <= 0x007F)) {
2950 // we only need one byte: ASCII table
2954 if (current > 0x07FF) {
2957 writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
2958 writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
2959 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
2961 // we can be 0 or between 0x0080 and 0x07FF
2962 // In that case we only need 2 bytes
2964 writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
2965 writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
2968 if (length >= 65535) {
2969 currentOffset = savedCurrentOffset - 1;
2972 stringIndex = UTF8Cache.put(stringCharArray, currentIndex++);
2973 // Now we know the length that we have to write in the constant pool
2974 // we use savedCurrentOffset to do that
2975 if (length > 65535) {
2978 poolContent[savedCurrentOffset] = (byte) (length >> 8);
2979 poolContent[savedCurrentOffset + 1] = (byte) length;
2981 index = stringCache.put(stringCharArray, currentIndex++);
2982 if (index > 0xFFFF){
2983 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
2985 // Write the tag first
2987 // Then the string index
2988 writeU2(stringIndex);
2993 * This method returns the index into the constantPool corresponding
2994 * nameAndType constant with nameIndex, typeIndex.
2996 * @param int nameIndex
2997 * @param int nameIndex
2998 * @param org.eclipse.jdt.internal.compiler.lookup.MethodBinding a methodBinding
2999 * @return <CODE>int</CODE>
3001 public int literalIndexForMethods(int nameIndex, int typeIndex, MethodBinding key) {
3003 int indexOfWellKnownMethodNameAndType;
3004 if ((indexOfWellKnownMethodNameAndType = indexOfWellKnownMethodNameAndType(key)) == -1) {
3005 // check if the entry exists
3006 if ((index = nameAndTypeCacheForMethods.get(key)) == -1) {
3007 // The entry doesn't exit yet
3008 index = nameAndTypeCacheForMethods.put(key, currentIndex++);
3009 if (index > 0xFFFF){
3010 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
3012 writeU1(NameAndTypeTag);
3017 if ((index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType]) == 0) {
3018 index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType] = currentIndex++;
3019 if (index > 0xFFFF){
3020 this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
3022 writeU1(NameAndTypeTag);
3030 * This method returns the index into the constantPool corresponding to the
3031 * method descriptor. It can be either an interface method reference constant
3032 * or a method reference constant.
3034 * @return <CODE>int</CODE>
3036 public int literalIndexForJavaLangObjectGetClass() {
3038 int nameAndTypeIndex;
3040 // Looking into the method ref table
3041 if ((index = wellKnownMethods[GETCLASS_OBJECT_METHOD]) == 0) {
3042 classIndex = literalIndexForJavaLangObject();
3043 if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
3044 int nameIndex = literalIndex(QualifiedNamesConstants.GetClass);
3045 int typeIndex = literalIndex(QualifiedNamesConstants.GetClassSignature);
3046 nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
3047 writeU1(NameAndTypeTag);
3051 index = wellKnownMethods[GETCLASS_OBJECT_METHOD] = currentIndex++;
3052 // Write the method ref constant into the constant pool
3053 // First add the tag
3054 writeU1(MethodRefTag);
3055 // Then write the class index
3056 writeU2(classIndex);
3057 // The write the nameAndType index
3058 writeU2(nameAndTypeIndex);
3063 * This method is used to clean the receiver in case of a clinit header is generated, but the
3064 * clinit has no code.
3065 * This implementation assumes that the clinit is the first method to be generated.
3066 * @see org.eclipse.jdt.internal.compiler.ast.TypeDeclaration#addClinit()
3068 public void resetForClinit(int constantPoolIndex, int constantPoolOffset) {
3069 currentIndex = constantPoolIndex;
3070 currentOffset = constantPoolOffset;
3071 if (UTF8Cache.get(AttributeNamesConstants.CodeName) >= constantPoolIndex) {
3072 UTF8Cache.remove(AttributeNamesConstants.CodeName);
3074 if (UTF8Cache.get(QualifiedNamesConstants.ClinitSignature) >= constantPoolIndex) {
3075 UTF8Cache.remove(QualifiedNamesConstants.ClinitSignature);
3077 if (UTF8Cache.get(QualifiedNamesConstants.Clinit) >= constantPoolIndex) {
3078 UTF8Cache.remove(QualifiedNamesConstants.Clinit);
3082 * Write a unsigned byte into the byte array
3084 * @param <CODE>int</CODE> The value to write into the byte array
3086 protected final void writeU1(int value) {
3088 poolContent[currentOffset++] = (byte) value;
3089 } catch (IndexOutOfBoundsException e) {
3090 //currentOffset has been ++ already (see the -1)
3091 int length = poolContent.length;
3092 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
3093 poolContent[currentOffset - 1] = (byte) value;
3097 * Write a unsigned byte into the byte array
3099 * @param <CODE>int</CODE> The value to write into the byte array
3101 protected final void writeU2(int value) {
3104 poolContent[currentOffset++] = (byte) (value >> 8);
3105 } catch (IndexOutOfBoundsException e) {
3106 //currentOffset has been ++ already (see the -1)
3107 int length = poolContent.length;
3108 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
3109 poolContent[currentOffset - 1] = (byte) (value >> 8);
3112 poolContent[currentOffset++] = (byte) value;
3113 } catch (IndexOutOfBoundsException e) {
3114 //currentOffset has been ++ already (see the -1)
3115 int length = poolContent.length;
3116 System.arraycopy(poolContent, 0, (poolContent = new byte[length + CONSTANTPOOL_GROW_SIZE]), 0, length);
3117 poolContent[currentOffset - 1] = (byte) value;