*******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
-import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.ClassFile;
-
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
/**
* This type is used to store all the constant pool entries.
*/
public static final int LONG_INITIAL_SIZE = 5;
public static final int UTF8_INITIAL_SIZE = 778;
public static final int STRING_INITIAL_SIZE = 761;
- public static final int FIELD_INITIAL_SIZE = 156;
- public static final int METHOD_INITIAL_SIZE = 236;
- public static final int INTERFACE_INITIAL_SIZE = 50;
+ public static final int METHODS_AND_FIELDS_INITIAL_SIZE = 450;
public static final int CLASS_INITIAL_SIZE = 86;
public static final int NAMEANDTYPE_INITIAL_SIZE = 272;
public static final int CONSTANTPOOL_INITIAL_SIZE = 2000;
protected LongCache longCache;
public CharArrayCache UTF8Cache;
protected CharArrayCache stringCache;
- protected ObjectCache fieldCache;
- protected ObjectCache methodCache;
- protected ObjectCache interfaceMethodCache;
- protected ObjectCache classCache;
- protected FieldNameAndTypeCache nameAndTypeCacheForFields;
- protected MethodNameAndTypeCache nameAndTypeCacheForMethods;
- int[] wellKnownTypes = new int[21];
- int[] wellKnownMethods = new int[36];
- int[] wellKnownFields = new int[10];
- int[] wellKnownFieldNameAndTypes = new int[2];
- int[] wellKnownMethodNameAndTypes = new int[33];
+ protected HashtableOfObject methodsAndFieldsCache;
+ protected CharArrayCache classCache;
+ protected HashtableOfObject nameAndTypeCacheForFieldsAndMethods;
public byte[] poolContent;
public int currentIndex = 1;
public int currentOffset;
- // predefined constant index for well known types
- final static int JAVA_LANG_BOOLEAN_TYPE = 0;
- final static int JAVA_LANG_BYTE_TYPE = 1;
- final static int JAVA_LANG_CHARACTER_TYPE = 2;
- final static int JAVA_LANG_DOUBLE_TYPE = 3;
- final static int JAVA_LANG_FLOAT_TYPE = 4;
- final static int JAVA_LANG_INTEGER_TYPE = 5;
- final static int JAVA_LANG_LONG_TYPE = 6;
- final static int JAVA_LANG_SHORT_TYPE = 7;
- final static int JAVA_LANG_VOID_TYPE = 8;
- final static int JAVA_LANG_CLASS_TYPE = 9;
- final static int JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE = 10;
- final static int JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE = 11;
- final static int JAVA_LANG_OBJECT_TYPE = 12;
- final static int JAVA_LANG_STRING_TYPE = 13;
- final static int JAVA_LANG_STRINGBUFFER_TYPE = 14;
- final static int JAVA_LANG_SYSTEM_TYPE = 15;
- final static int JAVA_LANG_THROWABLE_TYPE = 16;
- final static int JAVA_LANG_ERROR_TYPE = 17;
- final static int JAVA_LANG_EXCEPTION_TYPE = 18;
- final static int JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE = 19;
- final static int JAVA_LANG_ASSERTIONERROR_TYPE = 20;
-
- // predefined constant index for well known fields
- final static int TYPE_BYTE_FIELD = 0;
- final static int TYPE_SHORT_FIELD = 1;
- final static int TYPE_CHARACTER_FIELD = 2;
- final static int TYPE_INTEGER_FIELD = 3;
- final static int TYPE_LONG_FIELD = 4;
- final static int TYPE_FLOAT_FIELD = 5;
- final static int TYPE_DOUBLE_FIELD = 6;
- final static int TYPE_BOOLEAN_FIELD = 7;
- final static int TYPE_VOID_FIELD = 8;
- final static int OUT_SYSTEM_FIELD = 9;
- // predefined constant index for well known methods
- final static int FORNAME_CLASS_METHOD = 0;
- final static int NOCLASSDEFFOUNDERROR_CONSTR_METHOD = 1;
- final static int APPEND_INT_METHOD = 2;
- final static int APPEND_FLOAT_METHOD = 3;
- final static int APPEND_LONG_METHOD = 4;
- final static int APPEND_OBJECT_METHOD = 5;
- final static int APPEND_CHAR_METHOD = 6;
- final static int APPEND_STRING_METHOD = 7;
- final static int APPEND_BOOLEAN_METHOD = 8;
- final static int APPEND_DOUBLE_METHOD = 9;
- final static int STRINGBUFFER_STRING_CONSTR_METHOD = 10;
- final static int STRINGBUFFER_DEFAULT_CONSTR_METHOD = 11;
- final static int STRINGBUFFER_TOSTRING_METHOD = 12;
- final static int SYSTEM_EXIT_METHOD = 13;
- final static int THROWABLE_GETMESSAGE_METHOD = 14;
- final static int JAVALANGERROR_CONSTR_METHOD = 15;
- final static int NEWINSTANCE_CONSTRUCTOR_METHOD = 16;
- final static int STRING_INTERN_METHOD = 17;
- final static int VALUEOF_INT_METHOD = 18;
- final static int VALUEOF_FLOAT_METHOD = 19;
- final static int VALUEOF_LONG_METHOD = 20;
- final static int VALUEOF_OBJECT_METHOD = 21;
- final static int VALUEOF_CHAR_METHOD = 22;
- final static int VALUEOF_BOOLEAN_METHOD = 23;
- final static int VALUEOF_DOUBLE_METHOD = 24;
- final static int ASSERTIONERROR_CONSTR_OBJECT_METHOD = 25;
- final static int ASSERTIONERROR_CONSTR_INT_METHOD = 26;
- final static int ASSERTIONERROR_CONSTR_LONG_METHOD = 27;
- final static int ASSERTIONERROR_CONSTR_FLOAT_METHOD = 28;
- final static int ASSERTIONERROR_CONSTR_DOUBLE_METHOD = 29;
- final static int ASSERTIONERROR_CONSTR_BOOLEAN_METHOD = 30;
- final static int ASSERTIONERROR_CONSTR_CHAR_METHOD = 31;
- final static int ASSERTIONERROR_DEFAULT_CONSTR_METHOD = 32;
- final static int DESIREDASSERTIONSTATUS_CLASS_METHOD = 33;
- final static int GETCLASS_OBJECT_METHOD = 34;
- final static int GETCOMPONENTTYPE_CLASS_METHOD = 35;
-
- // predefined constant index for well known name and type for fields
- final static int TYPE_JAVALANGCLASS_NAME_AND_TYPE = 0;
- final static int OUT_SYSTEM_NAME_AND_TYPE = 1;
- // predefined constant index for well known name and type for methods
- final static int FORNAME_CLASS_METHOD_NAME_AND_TYPE = 0;
- final static int CONSTR_STRING_METHOD_NAME_AND_TYPE = 1;
- final static int DEFAULT_CONSTR_METHOD_NAME_AND_TYPE = 2;
- final static int APPEND_INT_METHOD_NAME_AND_TYPE = 3;
- final static int APPEND_FLOAT_METHOD_NAME_AND_TYPE = 4;
- final static int APPEND_LONG_METHOD_NAME_AND_TYPE = 5;
- final static int APPEND_OBJECT_METHOD_NAME_AND_TYPE = 6;
- final static int APPEND_CHAR_METHOD_NAME_AND_TYPE = 7;
- final static int APPEND_STRING_METHOD_NAME_AND_TYPE = 8;
- final static int APPEND_BOOLEAN_METHOD_NAME_AND_TYPE = 9;
- final static int APPEND_DOUBLE_METHOD_NAME_AND_TYPE = 10;
- final static int TOSTRING_METHOD_NAME_AND_TYPE = 11;
- final static int EXIT_METHOD_NAME_AND_TYPE = 12;
- final static int GETMESSAGE_METHOD_NAME_AND_TYPE = 13;
- final static int NEWINSTANCE_METHOD_NAME_AND_TYPE = 14;
- final static int INTERN_METHOD_NAME_AND_TYPE = 15;
- final static int VALUEOF_INT_METHOD_NAME_AND_TYPE = 16;
- final static int VALUEOF_FLOAT_METHOD_NAME_AND_TYPE = 17;
- final static int VALUEOF_LONG_METHOD_NAME_AND_TYPE = 18;
- final static int VALUEOF_OBJECT_METHOD_NAME_AND_TYPE = 19;
- final static int VALUEOF_CHAR_METHOD_NAME_AND_TYPE = 20;
- final static int VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE = 21;
- final static int VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE = 22;
- final static int CONSTR_INT_METHOD_NAME_AND_TYPE = 23;
- final static int CONSTR_LONG_METHOD_NAME_AND_TYPE = 24;
- final static int CONSTR_FLOAT_METHOD_NAME_AND_TYPE = 25;
- final static int CONSTR_DOUBLE_METHOD_NAME_AND_TYPE = 26;
- final static int CONSTR_OBJECT_METHOD_NAME_AND_TYPE = 27;
- final static int CONSTR_CHAR_METHOD_NAME_AND_TYPE = 28;
- final static int CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE = 29;
- final static int DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE = 30;
- final static int GETCLASS_OBJECT_METHOD_NAME_AND_TYPE = 31;
- final static int GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE = 32;
-
+
public ClassFile classFile;
+ public static final char[] Append = "append".toCharArray(); //$NON-NLS-1$
+ public static final char[] ARRAY_NEWINSTANCE_NAME = "newInstance".toCharArray(); //$NON-NLS-1$
+ public static final char[] ARRAY_NEWINSTANCE_SIGNATURE = "(Ljava/lang/Class;[I)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ArrayCopy = "arraycopy".toCharArray(); //$NON-NLS-1$
+ public static final char[] ArrayCopySignature = "(Ljava/lang/Object;ILjava/lang/Object;II)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] ArrayJavaLangClassConstantPoolName = "[Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ArrayJavaLangObjectConstantPoolName = "[Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ public static final char[] booleanBooleanSignature = "(Z)Ljava/lang/Boolean;".toCharArray(); //$NON-NLS-1$
+ public static final char[] BooleanConstrSignature = "(Z)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] BOOLEANVALUE_BOOLEAN_METHOD_NAME = "booleanValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] BOOLEANVALUE_BOOLEAN_METHOD_SIGNATURE = "()Z".toCharArray(); //$NON-NLS-1$
+ public static final char[] byteByteSignature = "(B)Ljava/lang/Byte;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ByteConstrSignature = "(B)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] BYTEVALUE_BYTE_METHOD_NAME = "byteValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] BYTEVALUE_BYTE_METHOD_SIGNATURE = "()B".toCharArray(); //$NON-NLS-1$
+ public static final char[] charCharacterSignature = "(C)Ljava/lang/Character;".toCharArray(); //$NON-NLS-1$
+ public static final char[] CharConstrSignature = "(C)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] CHARVALUE_CHARACTER_METHOD_NAME = "charValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] CHARVALUE_CHARACTER_METHOD_SIGNATURE = "()C".toCharArray(); //$NON-NLS-1$
+ public static final char[] Clinit = "<clinit>".toCharArray(); //$NON-NLS-1$
+ public static final char[] DefaultConstructorSignature = "()V".toCharArray(); //$NON-NLS-1$
+ public static final char[] ClinitSignature = DefaultConstructorSignature;
+ public static final char[] DesiredAssertionStatus = "desiredAssertionStatus".toCharArray(); //$NON-NLS-1$
+ public static final char[] DesiredAssertionStatusSignature = "()Z".toCharArray(); //$NON-NLS-1$
+ public static final char[] DoubleConstrSignature = "(D)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] doubleDoubleSignature = "(D)Ljava/lang/Double;".toCharArray(); //$NON-NLS-1$
+ public static final char[] DOUBLEVALUE_DOUBLE_METHOD_NAME = "doubleValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] DOUBLEVALUE_DOUBLE_METHOD_SIGNATURE = "()D".toCharArray(); //$NON-NLS-1$
+ public static final char[] Equals = "equals".toCharArray(); //$NON-NLS-1$
+ public static final char[] EqualsSignature = "(Ljava/lang/Object;)Z".toCharArray(); //$NON-NLS-1$
+ public static final char[] Exit = "exit".toCharArray(); //$NON-NLS-1$
+ public static final char[] ExitIntSignature = "(I)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] FloatConstrSignature = "(F)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] floatFloatSignature = "(F)Ljava/lang/Float;".toCharArray(); //$NON-NLS-1$
+ public static final char[] FLOATVALUE_FLOAT_METHOD_NAME = "floatValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] FLOATVALUE_FLOAT_METHOD_SIGNATURE = "()F".toCharArray(); //$NON-NLS-1$
+ public static final char[] ForName = "forName".toCharArray(); //$NON-NLS-1$
+ public static final char[] ForNameSignature = "(Ljava/lang/String;)Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_BOOLEAN_METHOD_NAME = "getBoolean".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_BOOLEAN_METHOD_SIGNATURE = "(Ljava/lang/Object;)Z".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_BYTE_METHOD_NAME = "getByte".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_BYTE_METHOD_SIGNATURE = "(Ljava/lang/Object;)B".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_CHAR_METHOD_NAME = "getChar".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_CHAR_METHOD_SIGNATURE = "(Ljava/lang/Object;)C".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_DOUBLE_METHOD_NAME = "getDouble".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_DOUBLE_METHOD_SIGNATURE = "(Ljava/lang/Object;)D".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_FLOAT_METHOD_NAME = "getFloat".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_FLOAT_METHOD_SIGNATURE = "(Ljava/lang/Object;)F".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_INT_METHOD_NAME = "getInt".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_INT_METHOD_SIGNATURE = "(Ljava/lang/Object;)I".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_LONG_METHOD_NAME = "getLong".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_LONG_METHOD_SIGNATURE = "(Ljava/lang/Object;)J".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_OBJECT_METHOD_NAME = "get".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_OBJECT_METHOD_SIGNATURE = "(Ljava/lang/Object;)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_SHORT_METHOD_NAME = "getShort".toCharArray(); //$NON-NLS-1$
+ public static final char[] GET_SHORT_METHOD_SIGNATURE = "(Ljava/lang/Object;)S".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetClass = "getClass".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetClassSignature = "()Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetComponentType = "getComponentType".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetComponentTypeSignature = GetClassSignature;
+ public static final char[] GetConstructor = "getConstructor".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetConstructorSignature = "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;".toCharArray(); //$NON-NLS-1$
+ public static final char[] GETDECLAREDCONSTRUCTOR_NAME = "getDeclaredConstructor".toCharArray(); //$NON-NLS-1$
+ public static final char[] GETDECLAREDCONSTRUCTOR_SIGNATURE = "([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;".toCharArray(); //$NON-NLS-1$
+ // predefined methods constant names
+ public static final char[] GETDECLAREDFIELD_NAME = "getDeclaredField".toCharArray(); //$NON-NLS-1$
+ public static final char[] GETDECLAREDFIELD_SIGNATURE = "(Ljava/lang/String;)Ljava/lang/reflect/Field;".toCharArray(); //$NON-NLS-1$
+ public static final char[] GETDECLAREDMETHOD_NAME = "getDeclaredMethod".toCharArray(); //$NON-NLS-1$
+ public static final char[] GETDECLAREDMETHOD_SIGNATURE = "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetMessage = "getMessage".toCharArray(); //$NON-NLS-1$
+ public static final char[] GetMessageSignature = "()Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] HasNext = "hasNext".toCharArray();//$NON-NLS-1$
+ public static final char[] HasNextSignature = "()Z".toCharArray();//$NON-NLS-1$
+ public static final char[] Init = "<init>".toCharArray(); //$NON-NLS-1$
+ public static final char[] IntConstrSignature = "(I)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] Intern = "intern".toCharArray(); //$NON-NLS-1$
+ public static final char[] InternSignature = GetMessageSignature;
+ public static final char[] IntIntegerSignature = "(I)Ljava/lang/Integer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] INTVALUE_INTEGER_METHOD_NAME = "intValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] INTVALUE_INTEGER_METHOD_SIGNATURE = "()I".toCharArray(); //$NON-NLS-1$
+ public static final char[] INVOKE_METHOD_METHOD_NAME = "invoke".toCharArray(); //$NON-NLS-1$
+ public static final char[] INVOKE_METHOD_METHOD_SIGNATURE = "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ public static final char[][] JAVA_LANG_REFLECT_ACCESSIBLEOBJECT = new char[][] {TypeConstants.JAVA, TypeConstants.LANG, TypeConstants.REFLECT, "AccessibleObject".toCharArray()}; //$NON-NLS-1$
+ public static final char[][] JAVA_LANG_REFLECT_ARRAY = new char[][] {TypeConstants.JAVA, TypeConstants.LANG, TypeConstants.REFLECT, "Array".toCharArray()}; //$NON-NLS-1$
+ // predefined type constant names
+ public static final char[][] JAVA_LANG_REFLECT_FIELD = new char[][] {TypeConstants.JAVA, TypeConstants.LANG, TypeConstants.REFLECT, "Field".toCharArray()}; //$NON-NLS-1$
+ public static final char[][] JAVA_LANG_REFLECT_METHOD = new char[][] {TypeConstants.JAVA, TypeConstants.LANG, TypeConstants.REFLECT, "Method".toCharArray()}; //$NON-NLS-1$
+ public static final char[] JavaIoPrintStreamSignature = "Ljava/io/PrintStream;".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangAssertionErrorConstantPoolName = "java/lang/AssertionError".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangBooleanConstantPoolName = "java/lang/Boolean".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangByteConstantPoolName = "java/lang/Byte".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangCharacterConstantPoolName = "java/lang/Character".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangClassConstantPoolName = "java/lang/Class".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangClassNotFoundExceptionConstantPoolName = "java/lang/ClassNotFoundException".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangClassSignature = "Ljava/lang/Class;".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangDoubleConstantPoolName = "java/lang/Double".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangErrorConstantPoolName = "java/lang/Error".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangExceptionConstantPoolName = "java/lang/Exception".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangFloatConstantPoolName = "java/lang/Float".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangIllegalArgumentExceptionConstantPoolName = "java/lang/IllegalArgumentException".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangIntegerConstantPoolName = "java/lang/Integer".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangLongConstantPoolName = "java/lang/Long".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangNoClassDefFoundErrorConstantPoolName = "java/lang/NoClassDefFoundError".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangObjectConstantPoolName = "java/lang/Object".toCharArray(); //$NON-NLS-1$
+ public static final char[] JAVALANGREFLECTACCESSIBLEOBJECT_CONSTANTPOOLNAME = "java/lang/reflect/AccessibleObject".toCharArray(); //$NON-NLS-1$
+ public static final char[] JAVALANGREFLECTARRAY_CONSTANTPOOLNAME = "java/lang/reflect/Array".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangReflectConstructor = "java/lang/reflect/Constructor".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangReflectConstructorNewInstanceSignature = "([Ljava/lang/Object;)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ public static final char[] JAVALANGREFLECTFIELD_CONSTANTPOOLNAME = "java/lang/reflect/Field".toCharArray(); //$NON-NLS-1$
+ public static final char[] JAVALANGREFLECTMETHOD_CONSTANTPOOLNAME = "java/lang/reflect/Method".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangShortConstantPoolName = "java/lang/Short".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangStringBufferConstantPoolName = "java/lang/StringBuffer".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangStringBuilderConstantPoolName = "java/lang/StringBuilder".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangStringConstantPoolName = "java/lang/String".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangStringSignature = "Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangSystemConstantPoolName = "java/lang/System".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangThrowableConstantPoolName = "java/lang/Throwable".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaLangVoidConstantPoolName = "java/lang/Void".toCharArray(); //$NON-NLS-1$
+ public static final char[] JavaUtilIteratorConstantPoolName = "java/util/Iterator".toCharArray(); //$NON-NLS-1$
+ public static final char[] LongConstrSignature = "(J)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] longLongSignature = "(J)Ljava/lang/Long;".toCharArray(); //$NON-NLS-1$
+ public static final char[] LONGVALUE_LONG_METHOD_NAME = "longValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] LONGVALUE_LONG_METHOD_SIGNATURE = "()J".toCharArray(); //$NON-NLS-1$
+ public static final char[] Name = "name".toCharArray(); //$NON-NLS-1$
+ public static final char[] NameSignature = "()Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] NewInstance = "newInstance".toCharArray(); //$NON-NLS-1$
+ public static final char[] NewInstanceSignature = "(Ljava/lang/Class;[I)Ljava/lang/Object;".toCharArray(); //$NON-NLS-1$
+ public static final char[] Next = "next".toCharArray();//$NON-NLS-1$
+ public static final char[] NextSignature = "()Ljava/lang/Object;".toCharArray();//$NON-NLS-1$
+ public static final char[] ObjectConstrSignature = "(Ljava/lang/Object;)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] Ordinal = "ordinal".toCharArray(); //$NON-NLS-1$
+ public static final char[] OrdinalSignature = "()I".toCharArray(); //$NON-NLS-1$
+ public static final char[] Out = "out".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_BOOLEAN_METHOD_NAME = "setBoolean".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_BOOLEAN_METHOD_SIGNATURE = "(Ljava/lang/Object;Z)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_BYTE_METHOD_NAME = "setByte".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_BYTE_METHOD_SIGNATURE = "(Ljava/lang/Object;B)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_CHAR_METHOD_NAME = "setChar".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_CHAR_METHOD_SIGNATURE = "(Ljava/lang/Object;C)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_DOUBLE_METHOD_NAME = "setDouble".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_DOUBLE_METHOD_SIGNATURE = "(Ljava/lang/Object;D)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_FLOAT_METHOD_NAME = "setFloat".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_FLOAT_METHOD_SIGNATURE = "(Ljava/lang/Object;F)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_INT_METHOD_NAME = "setInt".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_INT_METHOD_SIGNATURE = "(Ljava/lang/Object;I)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_LONG_METHOD_NAME = "setLong".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_LONG_METHOD_SIGNATURE = "(Ljava/lang/Object;J)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_OBJECT_METHOD_NAME = "set".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_OBJECT_METHOD_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_SHORT_METHOD_NAME = "setShort".toCharArray(); //$NON-NLS-1$
+ public static final char[] SET_SHORT_METHOD_SIGNATURE = "(Ljava/lang/Object;S)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] SETACCESSIBLE_NAME = "setAccessible".toCharArray(); //$NON-NLS-1$
+ public static final char[] SETACCESSIBLE_SIGNATURE = "(Z)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] ShortConstrSignature = "(S)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] shortShortSignature = "(S)Ljava/lang/Short;".toCharArray(); //$NON-NLS-1$
+ public static final char[] SHORTVALUE_SHORT_METHOD_NAME = "shortValue".toCharArray(); //$NON-NLS-1$
+ public static final char[] SHORTVALUE_SHORT_METHOD_SIGNATURE = "()S".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendBooleanSignature = "(Z)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendCharSignature = "(C)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendDoubleSignature = "(D)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendFloatSignature = "(F)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendIntSignature = "(I)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendLongSignature = "(J)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendObjectSignature = "(Ljava/lang/Object;)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBufferAppendStringSignature = "(Ljava/lang/String;)Ljava/lang/StringBuffer;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendBooleanSignature = "(Z)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendCharSignature = "(C)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendDoubleSignature = "(D)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendFloatSignature = "(F)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendIntSignature = "(I)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendLongSignature = "(J)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendObjectSignature = "(Ljava/lang/Object;)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringBuilderAppendStringSignature = "(Ljava/lang/String;)Ljava/lang/StringBuilder;".toCharArray(); //$NON-NLS-1$
+ public static final char[] StringConstructorSignature = "(Ljava/lang/String;)V".toCharArray(); //$NON-NLS-1$
+ public static final char[] This = "this".toCharArray(); //$NON-NLS-1$
+ public static final char[] ToString = "toString".toCharArray(); //$NON-NLS-1$
+ public static final char[] ToStringSignature = GetMessageSignature;
+ public static final char[] TYPE = "TYPE".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOf = "valueOf".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfBooleanSignature = "(Z)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfCharSignature = "(C)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfDoubleSignature = "(D)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfFloatSignature = "(F)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfIntSignature = "(I)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfLongSignature = "(J)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
+ public static final char[] ValueOfObjectSignature = "(Ljava/lang/Object;)Ljava/lang/String;".toCharArray(); //$NON-NLS-1$
/**
* ConstantPool constructor comment.
public ConstantPool(ClassFile classFile) {
this.UTF8Cache = new CharArrayCache(UTF8_INITIAL_SIZE);
this.stringCache = new CharArrayCache(STRING_INITIAL_SIZE);
- this.fieldCache = new ObjectCache(FIELD_INITIAL_SIZE);
- this.methodCache = new ObjectCache(METHOD_INITIAL_SIZE);
- this.interfaceMethodCache = new ObjectCache(INTERFACE_INITIAL_SIZE);
- this.classCache = new ObjectCache(CLASS_INITIAL_SIZE);
- this.nameAndTypeCacheForMethods = new MethodNameAndTypeCache(NAMEANDTYPE_INITIAL_SIZE);
- this.nameAndTypeCacheForFields = new FieldNameAndTypeCache(NAMEANDTYPE_INITIAL_SIZE);
+ this.methodsAndFieldsCache = new HashtableOfObject(METHODS_AND_FIELDS_INITIAL_SIZE);
+ this.classCache = new CharArrayCache(CLASS_INITIAL_SIZE);
+ this.nameAndTypeCacheForFieldsAndMethods = new HashtableOfObject(NAMEANDTYPE_INITIAL_SIZE);
this.poolContent = classFile.header;
this.currentOffset = classFile.headerOffset;
// currentOffset is initialized to 0 by default
System.arraycopy(poolContent, 0, (poolContent = new byte[currentOffset]), 0, currentOffset);
return poolContent;
}
-/**
- * Return the index of the @fieldBinding.
- *
- * Returns -1 if the @fieldBinding is not a predefined fieldBinding,
- * the right index otherwise.
- *
- * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
- * @return <CODE>int</CODE>
- */
-public int indexOfWellKnownFieldNameAndType(FieldBinding fieldBinding) {
- if ((fieldBinding.type.id == T_JavaLangClass) && (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE)))
- return TYPE_JAVALANGCLASS_NAME_AND_TYPE;
- if ((fieldBinding.type.id == T_JavaIoPrintStream) && (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.Out)))
- return OUT_SYSTEM_NAME_AND_TYPE;
- return -1;
-}
-/**
- * Return the index of the @fieldBinding.
- *
- * Returns -1 if the @fieldBinding is not a predefined fieldBinding,
- * the right index otherwise.
- *
- * @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
- * @return <CODE>int</CODE>
- */
-public int indexOfWellKnownFields(FieldBinding fieldBinding) {
- switch (fieldBinding.declaringClass.id) {
- case T_JavaLangByte :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_BYTE_FIELD;
- break;
- case T_JavaLangShort :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_SHORT_FIELD;
- break;
- case T_JavaLangCharacter :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_CHARACTER_FIELD;
- break;
- case T_JavaLangInteger :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_INTEGER_FIELD;
- break;
- case T_JavaLangLong :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_LONG_FIELD;
- break;
- case T_JavaLangFloat :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_FLOAT_FIELD;
- break;
- case T_JavaLangDouble :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_DOUBLE_FIELD;
- break;
- case T_JavaLangBoolean :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_BOOLEAN_FIELD;
- break;
- case T_JavaLangVoid :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.TYPE))
- return TYPE_VOID_FIELD;
- break;
- case T_JavaLangSystem :
- if (CharOperation.equals(fieldBinding.name, QualifiedNamesConstants.Out))
- return OUT_SYSTEM_FIELD;
- }
- return -1;
-}
-/**
- * Return the index of the @methodBinding.
- *
- * Returns -1 if the @methodBinding is not a predefined methodBinding,
- * the right index otherwise.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
- * @return <CODE>int</CODE>
- */
-public int indexOfWellKnownMethodNameAndType(MethodBinding methodBinding) {
- char firstChar = methodBinding.selector[0];
- switch (firstChar) {
- case 'f' :
- if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (methodBinding.returnType.id == T_JavaLangClass) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ForName))) {
- // This method binding is forName(java.lang.String)
- return FORNAME_CLASS_METHOD_NAME_AND_TYPE;
- }
- break;
- case '<' :
- if (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
- switch(methodBinding.parameters.length) {
- case 1:
- switch(methodBinding.parameters[0].id) {
- case T_String :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.StringConstructorSignature)) {
- return CONSTR_STRING_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_Object :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorObjectConstrSignature)) {
- return CONSTR_OBJECT_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_int :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorIntConstrSignature)) {
- return CONSTR_INT_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_char :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorCharConstrSignature)) {
- return CONSTR_CHAR_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_boolean :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorBooleanConstrSignature)) {
- return CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_float :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorFloatConstrSignature)) {
- return CONSTR_FLOAT_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_double :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorDoubleConstrSignature)) {
- return CONSTR_DOUBLE_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- case T_long :
- if (CharOperation.equals(methodBinding.signature(), QualifiedNamesConstants.AssertionErrorLongConstrSignature)) {
- return CONSTR_LONG_METHOD_NAME_AND_TYPE;
- } else {
- return -1;
- }
- }
- case 0:
- if (methodBinding.signature().length == 3) {
- return DEFAULT_CONSTR_METHOD_NAME_AND_TYPE;
- }
- }
- }
- break;
- case 'a' :
- if ((methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
- switch (methodBinding.parameters[0].id) {
- case T_int :
- case T_byte :
- case T_short :
- // This method binding is append(int)
- return APPEND_INT_METHOD_NAME_AND_TYPE;
- case T_float :
- // This method binding is append(float)
- return APPEND_FLOAT_METHOD_NAME_AND_TYPE;
- case T_long :
- // This method binding is append(long)
- return APPEND_LONG_METHOD_NAME_AND_TYPE;
- case T_JavaLangObject :
- // This method binding is append(java.lang.Object)
- return APPEND_OBJECT_METHOD_NAME_AND_TYPE;
- case T_char :
- // This method binding is append(char)
- return APPEND_CHAR_METHOD_NAME_AND_TYPE;
- case T_JavaLangString :
- // This method binding is append(java.lang.String)
- return APPEND_STRING_METHOD_NAME_AND_TYPE;
- case T_boolean :
- // This method binding is append(boolean)
- return APPEND_BOOLEAN_METHOD_NAME_AND_TYPE;
- case T_double :
- // This method binding is append(double)
- return APPEND_DOUBLE_METHOD_NAME_AND_TYPE;
- }
- }
- break;
- case 't' :
- if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
- // This method binding is toString()
- return TOSTRING_METHOD_NAME_AND_TYPE;
- }
- break;
- case 'v' :
- if ((methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
- switch(methodBinding.parameters[0].id) {
- case T_Object:
- return VALUEOF_OBJECT_METHOD_NAME_AND_TYPE;
- case T_int:
- case T_short:
- case T_byte:
- return VALUEOF_INT_METHOD_NAME_AND_TYPE;
- case T_long:
- return VALUEOF_LONG_METHOD_NAME_AND_TYPE;
- case T_float:
- return VALUEOF_FLOAT_METHOD_NAME_AND_TYPE;
- case T_double:
- return VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE;
- case T_boolean:
- return VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE;
- case T_char:
- return VALUEOF_CHAR_METHOD_NAME_AND_TYPE;
- }
- }
- break;
- case 'e' :
- if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
- // This method binding is exit(int)
- return EXIT_METHOD_NAME_AND_TYPE;
- }
- break;
- case 'g' :
- if ((methodBinding.selector.length == 10)
- && (methodBinding.parameters.length == 0)
- && (methodBinding.returnType.id == T_JavaLangString)
- && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
- // This method binding is getMessage()
- return GETMESSAGE_METHOD_NAME_AND_TYPE;
- }
- if (methodBinding.parameters.length == 0
- && methodBinding.returnType.id == T_JavaLangClass
- && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
- return GETCLASS_OBJECT_METHOD_NAME_AND_TYPE;
- }
- if (methodBinding.parameters.length == 0
- && methodBinding.returnType.id == T_JavaLangClass
- && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetComponentType)) {
- return GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE;
- }
- break;
- case 'i' :
- if ((methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
- // This method binding is toString()
- return INTERN_METHOD_NAME_AND_TYPE;
- }
+private int getFromCache(char[] declaringClass, char[] name, char[] signature) {
+ HashtableOfObject value = (HashtableOfObject) this.methodsAndFieldsCache.get(declaringClass);
+ if (value == null) {
+ return -1;
}
- return -1;
-}
-/**
- * Return the index of the @methodBinding.
- *
- * Returns -1 if the @methodBinding is not a predefined methodBinding,
- * the right index otherwise.
- *
- * @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
- * @return <CODE>int</CODE>
- */
-public int indexOfWellKnownMethods(MethodBinding methodBinding) {
- char firstChar = methodBinding.selector[0];
- switch (methodBinding.declaringClass.id) {
- case T_JavaLangClass :
- 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))) {
- // This method binding is forName(java.lang.String)
- return FORNAME_CLASS_METHOD;
- } else if ((firstChar == 'd') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_boolean) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.DesiredAssertionStatus)) {
- return DESIREDASSERTIONSTATUS_CLASS_METHOD;
- } else if ((firstChar == 'g') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangClass) && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetComponentType)) {
- return GETCOMPONENTTYPE_CLASS_METHOD;
- }
- break;
- case T_JavaLangNoClassDefError :
- if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
- // This method binding is NoClassDefFoundError(java.lang.String)
- return NOCLASSDEFFOUNDERROR_CONSTR_METHOD;
- }
- break;
- case T_JavaLangReflectConstructor :
- 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)) {
- return NEWINSTANCE_CONSTRUCTOR_METHOD;
- }
- break;
- case T_JavaLangStringBuffer :
- if ((firstChar == 'a') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangStringBuffer) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Append))) {
- switch (methodBinding.parameters[0].id) {
- case T_int :
- case T_byte :
- case T_short :
- // This method binding is append(int)
- return APPEND_INT_METHOD;
- case T_float :
- // This method binding is append(float)
- return APPEND_FLOAT_METHOD;
- case T_long :
- // This method binding is append(long)
- return APPEND_LONG_METHOD;
- case T_JavaLangObject :
- // This method binding is append(java.lang.Object)
- return APPEND_OBJECT_METHOD;
- case T_char :
- // This method binding is append(char)
- return APPEND_CHAR_METHOD;
- case T_JavaLangString :
- // This method binding is append(java.lang.String)
- return APPEND_STRING_METHOD;
- case T_boolean :
- // This method binding is append(boolean)
- return APPEND_BOOLEAN_METHOD;
- case T_double :
- // This method binding is append(double)
- return APPEND_DOUBLE_METHOD;
- }
- } else
- if ((firstChar == 't') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ToString))) {
- // This method binding is toString()
- return STRINGBUFFER_TOSTRING_METHOD;
- } else
- if ((firstChar == '<') && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init))) {
- if ((methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_JavaLangString)) {
- // This method binding is <init>(String)
- return STRINGBUFFER_STRING_CONSTR_METHOD;
- } else {
- if (methodBinding.parameters.length == 0) {
- // This method binding is <init>()
- return STRINGBUFFER_DEFAULT_CONSTR_METHOD;
- }
- }
- }
- break;
- case T_JavaLangString :
- if ((firstChar == 'v') && (methodBinding.parameters.length == 1) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.ValueOf))) {
- // This method binding is valueOf(java.lang.Object)
- switch (methodBinding.parameters[0].id) {
- case T_Object :
- return VALUEOF_OBJECT_METHOD;
- case T_int :
- case T_short :
- case T_byte :
- return VALUEOF_INT_METHOD;
- case T_long :
- return VALUEOF_LONG_METHOD;
- case T_float :
- return VALUEOF_FLOAT_METHOD;
- case T_double :
- return VALUEOF_DOUBLE_METHOD;
- case T_boolean :
- return VALUEOF_BOOLEAN_METHOD;
- case T_char :
- return VALUEOF_CHAR_METHOD;
- }
- } else
- if ((firstChar == 'i') && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Intern))) {
- // This method binding is valueOf(java.lang.Object)
- return STRING_INTERN_METHOD;
- }
- break;
- case T_JavaLangSystem :
- if ((firstChar == 'e') && (methodBinding.parameters.length == 1) && (methodBinding.parameters[0].id == T_int) && (methodBinding.returnType.id == T_void) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Exit))) {
- // This method binding is exit(int)
- return SYSTEM_EXIT_METHOD;
- }
- break;
- case T_JavaLangThrowable :
- if ((firstChar == 'g') && (methodBinding.selector.length == 10) && (methodBinding.parameters.length == 0) && (methodBinding.returnType.id == T_JavaLangString) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetMessage))) {
- // This method binding is getMessage()
- return THROWABLE_GETMESSAGE_METHOD;
- }
- break;
- case T_JavaLangError :
- if ((firstChar == '<') && (methodBinding.parameters.length == 1) && (CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) && (methodBinding.parameters[0].id == T_String)) {
- return JAVALANGERROR_CONSTR_METHOD;
- }
- break;
- case T_JavaLangAssertionError :
- if ((firstChar == '<') && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.Init)) {
- switch (methodBinding.parameters.length) {
- case 0:
- return ASSERTIONERROR_DEFAULT_CONSTR_METHOD;
- case 1:
- switch(methodBinding.parameters[0].id) {
- case T_boolean :
- return ASSERTIONERROR_CONSTR_BOOLEAN_METHOD;
- case T_char :
- return ASSERTIONERROR_CONSTR_CHAR_METHOD;
- case T_double :
- return ASSERTIONERROR_CONSTR_DOUBLE_METHOD;
- case T_int :
- case T_byte :
- case T_short :
- return ASSERTIONERROR_CONSTR_INT_METHOD;
- case T_float :
- return ASSERTIONERROR_CONSTR_FLOAT_METHOD;
- case T_long :
- return ASSERTIONERROR_CONSTR_LONG_METHOD;
- default:
- return ASSERTIONERROR_CONSTR_OBJECT_METHOD;
- }
- }
- }
- break;
- case T_JavaLangObject :
- if (methodBinding.parameters.length == 0
- && CharOperation.equals(methodBinding.selector, QualifiedNamesConstants.GetClass)) {
- return GETCLASS_OBJECT_METHOD;
- }
+ CharArrayCache value2 = (CharArrayCache) value.get(name);
+ if (value2 == null) {
+ return -1;
}
- return -1;
+ return value2.get(signature);
}
-/**
- * Return the index of the @typeBinding
- *
- * Returns -1 if the @typeBinding is not a predefined binding, the right index
- * otherwise.
- *
- * @param typeBinding org.eclipse.jdt.internal.compiler.lookup.TypeBinding
- * @return <CODE>int</CODE>
- */
-public int indexOfWellKnownTypes(TypeBinding typeBinding) {
- switch(typeBinding.id) {
- case T_JavaLangBoolean : return JAVA_LANG_BOOLEAN_TYPE;
- case T_JavaLangByte : return JAVA_LANG_BYTE_TYPE;
- case T_JavaLangCharacter : return JAVA_LANG_CHARACTER_TYPE;
- case T_JavaLangDouble : return JAVA_LANG_DOUBLE_TYPE;
- case T_JavaLangFloat : return JAVA_LANG_FLOAT_TYPE;
- case T_JavaLangInteger : return JAVA_LANG_INTEGER_TYPE;
- case T_JavaLangLong : return JAVA_LANG_LONG_TYPE;
- case T_JavaLangShort : return JAVA_LANG_SHORT_TYPE;
- case T_JavaLangVoid : return JAVA_LANG_VOID_TYPE;
- case T_JavaLangClass : return JAVA_LANG_CLASS_TYPE;
- case T_JavaLangClassNotFoundException : return JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE;
- case T_JavaLangNoClassDefError : return JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE;
- case T_JavaLangObject : return JAVA_LANG_OBJECT_TYPE;
- case T_JavaLangString : return JAVA_LANG_STRING_TYPE;
- case T_JavaLangStringBuffer : return JAVA_LANG_STRINGBUFFER_TYPE;
- case T_JavaLangSystem : return JAVA_LANG_SYSTEM_TYPE;
- case T_JavaLangThrowable : return JAVA_LANG_THROWABLE_TYPE;
- case T_JavaLangError : return JAVA_LANG_ERROR_TYPE;
- case T_JavaLangException : return JAVA_LANG_EXCEPTION_TYPE;
- case T_JavaLangReflectConstructor : return JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE;
- case T_JavaLangAssertionError : return JAVA_LANG_ASSERTIONERROR_TYPE;
+private int getFromNameAndTypeCache(char[] name, char[] signature) {
+ CharArrayCache value = (CharArrayCache) this.nameAndTypeCacheForFieldsAndMethods.get(name);
+ if (value == null) {
+ return -1;
}
- return -1;
+ return value.get(signature);
}
public int literalIndex(byte[] utf8encoding, char[] stringCharArray) {
int index;
*/
public int literalIndex(FieldBinding aFieldBinding) {
int index;
- int nameAndTypeIndex;
- int classIndex;
- int indexWellKnownField;
- if ((indexWellKnownField = indexOfWellKnownFields(aFieldBinding)) == -1) {
- if ((index = fieldCache.get(aFieldBinding)) < 0) {
- // The entry doesn't exit yet
- classIndex = literalIndex(aFieldBinding.declaringClass);
- nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
- index = fieldCache.put(aFieldBinding, currentIndex++);
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- } else {
- if ((index = wellKnownFields[indexWellKnownField]) == 0) {
- // that field need to be inserted
- classIndex = literalIndex(aFieldBinding.declaringClass);
- nameAndTypeIndex = literalIndexForFields(literalIndex(aFieldBinding.name), literalIndex(aFieldBinding.type.signature()), aFieldBinding);
- index = wellKnownFields[indexWellKnownField] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
+ final char[] name = aFieldBinding.name;
+ final char[] signature = aFieldBinding.type.signature();
+ final char[] declaringClassConstantPoolName = aFieldBinding.declaringClass.constantPoolName();
+ if ((index = getFromCache(declaringClassConstantPoolName, name, signature)) < 0) {
+ // The entry doesn't exit yet
+ int classIndex = literalIndexForType(declaringClassConstantPoolName);
+ int nameAndTypeIndex = literalIndexForFields(literalIndex(name), literalIndex(signature), name, signature);
+ index = putInCache(declaringClassConstantPoolName, name, signature, currentIndex++);
+ if (index > 0xFFFF){
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
+ writeU1(FieldRefTag);
+ writeU2(classIndex);
+ writeU2(nameAndTypeIndex);
}
return index;
}
*/
public int literalIndex(MethodBinding aMethodBinding) {
int index;
- int nameAndTypeIndex;
- int classIndex;
- int indexWellKnownMethod;
- if ((indexWellKnownMethod = indexOfWellKnownMethods(aMethodBinding)) == -1) {
- if (aMethodBinding.constantPoolDeclaringClass().isInterface()) {
- // Lookinf into the interface method ref table
- if ((index = interfaceMethodCache.get(aMethodBinding)) < 0) {
- classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
- nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
- index = interfaceMethodCache.put(aMethodBinding, currentIndex++);
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the interface method ref constant into the constant pool
- // First add the tag
- writeU1(InterfaceMethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- } else {
- // Lookinf into the method ref table
- if ((index = methodCache.get(aMethodBinding)) < 0) {
- classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
- nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
- index = methodCache.put(aMethodBinding, currentIndex++);
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- }
- } else {
- // This is a well known method
- if ((index = wellKnownMethods[indexWellKnownMethod]) == 0) {
- // this methods was not inserted yet
- if (aMethodBinding.constantPoolDeclaringClass().isInterface()) {
- // Lookinf into the interface method ref table
- classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
- nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
- index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the interface method ref constant into the constant pool
- // First add the tag
- writeU1(InterfaceMethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- } else {
- // Lookinf into the method ref table
- classIndex = literalIndex(aMethodBinding.constantPoolDeclaringClass());
- nameAndTypeIndex = literalIndexForMethods(literalIndex(aMethodBinding.constantPoolName()), literalIndex(aMethodBinding.signature()), aMethodBinding);
- index = wellKnownMethods[indexWellKnownMethod] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
+ final TypeBinding constantPoolDeclaringClass = aMethodBinding.constantPoolDeclaringClass();
+ final char[] declaringClassConstantPoolName = constantPoolDeclaringClass.constantPoolName();
+ final char[] selector = aMethodBinding.selector;
+ final char[] signature = aMethodBinding.signature();
+ if ((index = getFromCache(declaringClassConstantPoolName, selector, signature)) < 0) {
+ int classIndex = literalIndexForType(constantPoolDeclaringClass.constantPoolName());
+ int nameAndTypeIndex = literalIndexForMethods(literalIndex(selector), literalIndex(signature), selector, signature);
+ index = putInCache(declaringClassConstantPoolName, selector, signature, currentIndex++);
+ if (index > 0xFFFF){
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
+ // Write the interface method ref constant into the constant pool
+ // First add the tag
+ writeU1(constantPoolDeclaringClass.isInterface() || constantPoolDeclaringClass.isAnnotationType() ? InterfaceMethodRefTag : MethodRefTag);
+ // Then write the class index
+ writeU2(classIndex);
+ // The write the nameAndType index
+ writeU2(nameAndTypeIndex);
}
return index;
}
/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @param aTypeBinding TypeBinding
- * @return <CODE>int</CODE>
+ * This method returns the index into the constantPool corresponding to the type descriptor
+ * corresponding to a type constant pool name.
*/
-public int literalIndex(TypeBinding aTypeBinding) {
+public int literalIndexForType(final char[] constantPoolName) {
int index;
- int nameIndex;
- int indexWellKnownType;
- if ((indexWellKnownType = indexOfWellKnownTypes(aTypeBinding)) == -1) {
- if ((index = classCache.get(aTypeBinding)) < 0) {
+ if ((index = classCache.get(constantPoolName)) < 0) {
+ // The entry doesn't exit yet
+ int nameIndex = literalIndex(constantPoolName);
+ index = classCache.put(constantPoolName, currentIndex++);
+ if (index > 0xFFFF){
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
+ }
+ writeU1(ClassTag);
+ // Then add the 8 bytes representing the long
+ writeU2(nameIndex);
+ }
+ return index;
+}
+public int literalIndexForMethod(char[] declaringClass, char[] selector, char[] signature, boolean isInterface) {
+ int index = getFromCache(declaringClass, selector, signature);
+ if (index == -1) {
+ int classIndex;
+ if ((classIndex = classCache.get(declaringClass)) < 0) {
// The entry doesn't exit yet
- nameIndex = literalIndex(aTypeBinding.constantPoolName());
- index = classCache.put(aTypeBinding, currentIndex++);
+ int nameIndex = literalIndex(declaringClass);
+ classIndex = classCache.put(declaringClass, this.currentIndex++);
if (index > 0xFFFF){
this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
// Then add the 8 bytes representing the long
writeU2(nameIndex);
}
- } else {
- if ((index = wellKnownTypes[indexWellKnownType]) == 0) {
- // Need to insert that binding
- nameIndex = literalIndex(aTypeBinding.constantPoolName());
- index = wellKnownTypes[indexWellKnownType] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
+ int nameAndTypeIndex = literalIndexForMethod(selector, signature);
+ index = putInCache(declaringClass, selector, signature, currentIndex++);
+ if (index > 0xFFFF){
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
+ // Write the interface method ref constant into the constant pool
+ // First add the tag
+ writeU1(isInterface ? InterfaceMethodRefTag : MethodRefTag);
+ // Then write the class index
+ writeU2(classIndex);
+ // The write the nameAndType index
+ writeU2(nameAndTypeIndex);
}
return index;
}
-/**
- * This method returns the index into the constantPool corresponding
- * nameAndType constant with nameIndex, typeIndex.
- *
- * @param nameIndex int
- * @param typeIndex int
- * @param key org.eclipse.jdt.internal.compiler.lookup.FieldBinding
- * @return <CODE>int</CODE>
- */
-public int literalIndexForFields(int nameIndex, int typeIndex, FieldBinding key) {
- int index;
- int indexOfWellKnownFieldNameAndType;
- if ((indexOfWellKnownFieldNameAndType = indexOfWellKnownFieldNameAndType(key)) == -1) {
- // check if the entry already exists
- if ((index = nameAndTypeCacheForFields.get(key)) == -1) {
- // The entry doesn't exit yet
- index = nameAndTypeCacheForFields.put(key, currentIndex++);
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- } else {
- if ((index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType]) == 0) {
- index = wellKnownFieldNameAndTypes[indexOfWellKnownFieldNameAndType] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
+private int literalIndexForField(char[] name, char[] signature) {
+ int index = getFromNameAndTypeCache(name, signature);
+ if (index == -1) {
+ // The entry doesn't exit yet
+ int nameIndex = literalIndex(name);
+ int typeIndex = literalIndex(signature);
+ index = putInNameAndTypeCache(name, signature, currentIndex++);
+ if (index > 0xFFFF){
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
+ writeU1(NameAndTypeTag);
+ writeU2(nameIndex);
+ writeU2(typeIndex);
}
return index;
}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangBoolean() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE]) == 0) {
- int nameIndex;
+public int literalIndexForMethod(char[] selector, char[] signature) {
+ int index = getFromNameAndTypeCache(selector, signature);
+ if (index == -1) {
// The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangBooleanConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_BOOLEAN_TYPE] = currentIndex++;
+ int nameIndex = literalIndex(selector);
+ int typeIndex = literalIndex(signature);
+ index = putInNameAndTypeCache(selector, signature, currentIndex++);
if (index > 0xFFFF){
this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
+ writeU1(NameAndTypeTag);
writeU2(nameIndex);
+ writeU2(typeIndex);
}
return index;
}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangBooleanTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_BOOLEAN_FIELD]) == 0) {
- int nameAndTypeIndex;
+public int literalIndexForField(char[] declaringClass, char[] name, char[] signature) {
+ int index = getFromCache(declaringClass, name, signature);
+ if (index == -1) {
int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangBoolean();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
+ if ((classIndex = classCache.get(declaringClass)) < 0) {
+ // The entry doesn't exit yet
+ int nameIndex = literalIndex(declaringClass);
+ classIndex = classCache.put(declaringClass, this.currentIndex++);
+ if (index > 0xFFFF){
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
+ }
+ writeU1(ClassTag);
+ // Then add the 8 bytes representing the long
writeU2(nameIndex);
- writeU2(typeIndex);
}
- index = wellKnownFields[TYPE_BOOLEAN_FIELD] = currentIndex++;
+ int nameAndTypeIndex = literalIndexForField(name, signature);
+ index = putInCache(declaringClass, name, signature, currentIndex++);
if (index > 0xFFFF){
this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
+ // Write the interface method ref constant into the constant pool
+ // First add the tag
writeU1(FieldRefTag);
+ // Then write the class index
writeU2(classIndex);
- writeU2(nameAndTypeIndex);
+ // The write the nameAndType index
+ writeU2(nameAndTypeIndex);
}
return index;
}
/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
+ * This method returns the index into the constantPool corresponding
+ * nameAndType constant with nameIndex, typeIndex.
*
- * @return <CODE>int</CODE>
+ * @param nameIndex the given name index
+ * @param typeIndex the given type index
+ * @param name the given field name
+ * @param signature the given field signature
+ * @return the index into the constantPool corresponding
+ * nameAndType constant with nameIndex, typeInde
*/
-public int literalIndexForJavaLangByte() {
+private int literalIndexForFields(int nameIndex, int typeIndex, char[] name, char[] signature) {
int index;
- if ((index = wellKnownTypes[JAVA_LANG_BYTE_TYPE]) == 0) {
- int nameIndex;
+ if ((index = getFromNameAndTypeCache(name, signature)) == -1) {
// The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangByteConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_BYTE_TYPE] = currentIndex++;
+ index = putInNameAndTypeCache(name, signature, currentIndex++);
if (index > 0xFFFF){
this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
+ writeU1(NameAndTypeTag);
writeU2(nameIndex);
+ writeU2(typeIndex);
}
return index;
}
/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
+ * This method returns the index into the constantPool corresponding to the type descriptor.
*
+ * @param stringCharArray char[]
* @return <CODE>int</CODE>
*/
-public int literalIndexForJavaLangByteTYPE() {
+public int literalIndexForLdc(char[] stringCharArray) {
int index;
- if ((index = wellKnownFields[TYPE_BYTE_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
+ if ((index = stringCache.get(stringCharArray)) < 0) {
+ int stringIndex;
// The entry doesn't exit yet
- classIndex = literalIndexForJavaLangByte();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
+ if ((stringIndex = UTF8Cache.get(stringCharArray)) < 0) {
+ // The entry doesn't exit yet
+ // Write the tag first
+ writeU1(Utf8Tag);
+ // Then the size of the stringName array
+ int savedCurrentOffset = currentOffset;
+ if (currentOffset + 2 >= poolContent.length) {
+ // we need to resize the poolContent array because we won't have
+ // enough space to write the length
+ resizePoolContents(2);
+ }
+ currentOffset += 2;
+ int length = 0;
+ for (int i = 0; i < stringCharArray.length; i++) {
+ char current = stringCharArray[i];
+ if ((current >= 0x0001) && (current <= 0x007F)) {
+ // we only need one byte: ASCII table
+ writeU1(current);
+ length++;
+ } else
+ if (current > 0x07FF) {
+ // we need 3 bytes
+ length += 3;
+ writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
+ writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
+ writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
+ } else {
+ // we can be 0 or between 0x0080 and 0x07FF
+ // In that case we only need 2 bytes
+ length += 2;
+ writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
+ writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
+ }
+ }
+ if (length >= 65535) {
+ currentOffset = savedCurrentOffset - 1;
+ return -1;
+ }
+ stringIndex = UTF8Cache.put(stringCharArray, currentIndex++);
+ // Now we know the length that we have to write in the constant pool
+ // we use savedCurrentOffset to do that
+ if (length > 65535) {
+ return 0;
+ }
+ poolContent[savedCurrentOffset] = (byte) (length >> 8);
+ poolContent[savedCurrentOffset + 1] = (byte) length;
}
- index = wellKnownFields[TYPE_BYTE_FIELD] = currentIndex++;
+ index = stringCache.put(stringCharArray, currentIndex++);
if (index > 0xFFFF){
this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
+ // Write the tag first
+ writeU1(StringTag);
+ // Then the string index
+ writeU2(stringIndex);
}
return index;
}
/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
+ * This method returns the index into the constantPool corresponding
+ * nameAndType constant with nameIndex, typeIndex.
*
+ * @param nameIndex the given name index
+ * @param typeIndex the given type index
+ * @param selector the given method selector
+ * @param signature the given method signature
* @return <CODE>int</CODE>
*/
-public int literalIndexForJavaLangCharacter() {
+public int literalIndexForMethods(int nameIndex, int typeIndex, char[] selector, char[] signature) {
int index;
- if ((index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE]) == 0) {
- int nameIndex;
+ if ((index = getFromNameAndTypeCache(selector, signature)) == -1) {
// The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangCharacterConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_CHARACTER_TYPE] = currentIndex++;
+ index = putInNameAndTypeCache(selector, signature, currentIndex++);
if (index > 0xFFFF){
this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
}
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
+ writeU1(NameAndTypeTag);
writeU2(nameIndex);
+ writeU2(typeIndex);
+ }
+ return index;
+}
+private int putInNameAndTypeCache(final char[] key1, final char[] key2, int index) {
+ CharArrayCache value = (CharArrayCache) this.nameAndTypeCacheForFieldsAndMethods.get(key1);
+ if (value == null) {
+ CharArrayCache charArrayCache = new CharArrayCache();
+ charArrayCache.put(key2, index);
+ this.nameAndTypeCacheForFieldsAndMethods.put(key1, charArrayCache);
+ } else {
+ value.put(key2, index);
}
return index;
}
/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
+ * @param key1
+ * @param key2
+ * @param key3
+ * @param index
+ * @return the given index
*/
-public int literalIndexForJavaLangCharacterTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_CHARACTER_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangCharacter();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
+private int putInCache(final char[] key1, final char[] key2, final char[] key3, int index) {
+ HashtableOfObject value = (HashtableOfObject) this.methodsAndFieldsCache.get(key1);
+ if (value == null) {
+ value = new HashtableOfObject();
+ this.methodsAndFieldsCache.put(key1, value);
+ CharArrayCache charArrayCache = new CharArrayCache();
+ charArrayCache.put(key3, index);
+ value.put(key2, charArrayCache);
+ } else {
+ CharArrayCache charArrayCache = (CharArrayCache) value.get(key2);
+ if (charArrayCache == null) {
+ charArrayCache = new CharArrayCache();
+ charArrayCache.put(key3, index);
+ value.put(key2, charArrayCache);
+ } else {
+ charArrayCache.put(key3, index);
}
- index = wellKnownFields[TYPE_CHARACTER_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangClass() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_CLASS_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_CLASS_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangClassForName() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[FORNAME_CLASS_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangClass();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ForName);
- int typeIndex = literalIndex(QualifiedNamesConstants.ForNameSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[FORNAME_CLASS_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[FORNAME_CLASS_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangClassDesiredAssertionStatus() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangClass();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatus);
- int typeIndex = literalIndex(QualifiedNamesConstants.DesiredAssertionStatusSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[DESIREDASSERTIONSTATUS_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[DESIREDASSERTIONSTATUS_CLASS_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangClassGetComponentType() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[GETCOMPONENTTYPE_CLASS_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangClass();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.GetComponentType);
- int typeIndex = literalIndex(QualifiedNamesConstants.GetComponentTypeSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCOMPONENTTYPE_CLASS_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[GETCOMPONENTTYPE_CLASS_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangClassNotFoundException() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangClassNotFoundExceptionConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_CLASSNOTFOUNDEXCEPTION_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangDouble() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangDoubleConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_DOUBLE_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangDoubleTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_DOUBLE_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangDouble();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[TYPE_DOUBLE_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangError() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_ERROR_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangErrorConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_ERROR_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangErrorConstructor() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[JAVALANGERROR_CONSTR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-public int literalIndexForJavaLangException() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE]) == 0) {
- // The entry doesn't exit yet
- int nameIndex = literalIndex(QualifiedNamesConstants.JavaLangExceptionConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_EXCEPTION_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangFloat() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangFloatConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_FLOAT_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangFloatTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_FLOAT_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangFloat();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[TYPE_FLOAT_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangInteger() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangIntegerConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_INTEGER_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangIntegerTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_INTEGER_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangInteger();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[TYPE_INTEGER_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangLong() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_LONG_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangLongConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_LONG_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangLongTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_LONG_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangLong();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[TYPE_LONG_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangNoClassDefFoundError() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangNoClassDefFoundErrorConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_NOCLASSDEFFOUNDERROR_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangAssertionError() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangAssertionErrorConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_ASSERTIONERROR_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @param typeBindingID int
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangAssertionErrorConstructor(int typeBindingID) {
- int index = 0;
- int nameAndTypeIndex = 0;
- int classIndex = 0;
- switch (typeBindingID) {
- case T_int :
- case T_byte :
- case T_short :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorIntConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_INT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_long :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorLongConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_LONG_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_float :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorFloatConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_FLOAT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_double :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorDoubleConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_DOUBLE_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_char :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorCharConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_CHAR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_boolean :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorBooleanConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_BOOLEAN_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- //case T_Object :
- //case T_String :
- //case T_null :
- default :
- if ((index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.AssertionErrorObjectConstrSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_CONSTR_OBJECT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- }
- return index;
-}
-
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangAssertionErrorDefaultConstructor() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangAssertionError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[ASSERTIONERROR_DEFAULT_CONSTR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-
-
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangNoClassDefFoundErrorStringConstructor() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangNoClassDefFoundError();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[NOCLASSDEFFOUNDERROR_CONSTR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangObject() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangObjectConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_OBJECT_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangReflectConstructor() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangReflectConstructor);
- index = wellKnownTypes[JAVA_LANG_REFLECT_CONSTRUCTOR_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-public int literalIndexForJavaLangReflectConstructorNewInstance() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangReflectConstructor();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.NewInstance);
- int typeIndex = literalIndex(QualifiedNamesConstants.NewInstanceSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[NEWINSTANCE_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[NEWINSTANCE_CONSTRUCTOR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangShort() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_SHORT_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangShortConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_SHORT_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangShortTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_SHORT_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangShort();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[TYPE_SHORT_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangString() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_STRING_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_STRING_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringBuffer() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangStringBufferConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_STRINGBUFFER_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringBufferAppend(int typeID) {
- int index = 0;
- int nameAndTypeIndex = 0;
- int classIndex = 0;
- switch (typeID) {
- case T_int :
- case T_byte :
- case T_short :
- if ((index = wellKnownMethods[APPEND_INT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendIntSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_INT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_long :
- if ((index = wellKnownMethods[APPEND_LONG_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendLongSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_LONG_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_float :
- if ((index = wellKnownMethods[APPEND_FLOAT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendFloatSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_FLOAT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_double :
- if ((index = wellKnownMethods[APPEND_DOUBLE_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendDoubleSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_DOUBLE_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_char :
- if ((index = wellKnownMethods[APPEND_CHAR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendCharSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_CHAR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_boolean :
- if ((index = wellKnownMethods[APPEND_BOOLEAN_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendBooleanSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_BOOLEAN_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_Object :
- if ((index = wellKnownMethods[APPEND_OBJECT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendObjectSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_OBJECT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_String :
- case T_null :
- if ((index = wellKnownMethods[APPEND_STRING_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Append);
- int typeIndex = literalIndex(QualifiedNamesConstants.AppendStringSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[APPEND_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[APPEND_STRING_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringBufferConstructor() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.StringConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[CONSTR_STRING_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[STRINGBUFFER_STRING_CONSTR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringBufferDefaultConstructor() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Init);
- int typeIndex = literalIndex(QualifiedNamesConstants.DefaultConstructorSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[DEFAULT_CONSTR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[STRINGBUFFER_DEFAULT_CONSTR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringBufferToString() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangStringBuffer();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ToString);
- int typeIndex = literalIndex(QualifiedNamesConstants.ToStringSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[TOSTRING_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[STRINGBUFFER_TOSTRING_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringIntern() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[STRING_INTERN_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangString();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Intern);
- int typeIndex = literalIndex(QualifiedNamesConstants.InternSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[INTERN_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[STRING_INTERN_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangStringValueOf(int typeID) {
- int index = 0;
- int nameAndTypeIndex = 0;
- int classIndex = literalIndexForJavaLangString();
- switch (typeID) {
- case T_int :
- case T_byte :
- case T_short :
- if ((index = wellKnownMethods[VALUEOF_INT_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfIntSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_INT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_INT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_long :
- if ((index = wellKnownMethods[VALUEOF_LONG_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfLongSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_LONG_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_LONG_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_float :
- if ((index = wellKnownMethods[VALUEOF_FLOAT_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfFloatSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_FLOAT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_FLOAT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_double :
- if ((index = wellKnownMethods[VALUEOF_DOUBLE_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfDoubleSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_DOUBLE_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_DOUBLE_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_char :
- if ((index = wellKnownMethods[VALUEOF_CHAR_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfCharSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_CHAR_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_CHAR_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_boolean :
- if ((index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfBooleanSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_BOOLEAN_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_BOOLEAN_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- case T_Object :
- if ((index = wellKnownMethods[VALUEOF_OBJECT_METHOD]) == 0) {
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.ValueOf);
- int typeIndex = literalIndex(QualifiedNamesConstants.ValueOfObjectSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[VALUEOF_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[VALUEOF_OBJECT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- break;
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangSystem() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangSystemConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_SYSTEM_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangSystemExitInt() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[SYSTEM_EXIT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangSystem();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Exit);
- int typeIndex = literalIndex(QualifiedNamesConstants.ExitIntSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[EXIT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[SYSTEM_EXIT_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangSystemOut() {
- int index;
- if ((index = wellKnownFields[OUT_SYSTEM_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangSystem();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.Out);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaIoPrintStreamSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[OUT_SYSTEM_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[OUT_SYSTEM_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangThrowable() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangThrowableConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_THROWABLE_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangThrowableGetMessage() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangThrowable();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.GetMessage);
- int typeIndex = literalIndex(QualifiedNamesConstants.GetMessageSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[GETMESSAGE_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[THROWABLE_GETMESSAGE_METHOD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangVoid() {
- int index;
- if ((index = wellKnownTypes[JAVA_LANG_VOID_TYPE]) == 0) {
- int nameIndex;
- // The entry doesn't exit yet
- nameIndex = literalIndex(QualifiedNamesConstants.JavaLangVoidConstantPoolName);
- index = wellKnownTypes[JAVA_LANG_VOID_TYPE] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(ClassTag);
- // Then add the 8 bytes representing the long
- writeU2(nameIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool
- * corresponding to the field binding aFieldBinding.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangVoidTYPE() {
- int index;
- if ((index = wellKnownFields[TYPE_VOID_FIELD]) == 0) {
- int nameAndTypeIndex;
- int classIndex;
- // The entry doesn't exit yet
- classIndex = literalIndexForJavaLangVoid();
- if ((nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.TYPE);
- int typeIndex = literalIndex(QualifiedNamesConstants.JavaLangClassSignature);
- nameAndTypeIndex = wellKnownFieldNameAndTypes[TYPE_JAVALANGCLASS_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownFields[TYPE_VOID_FIELD] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(FieldRefTag);
- writeU2(classIndex);
- writeU2(nameAndTypeIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the type descriptor.
- *
- * @param stringCharArray char[]
- * @return <CODE>int</CODE>
- */
-public int literalIndexForLdc(char[] stringCharArray) {
- int index;
- if ((index = stringCache.get(stringCharArray)) < 0) {
- int stringIndex;
- // The entry doesn't exit yet
- if ((stringIndex = UTF8Cache.get(stringCharArray)) < 0) {
- // The entry doesn't exit yet
- // Write the tag first
- writeU1(Utf8Tag);
- // Then the size of the stringName array
- int savedCurrentOffset = currentOffset;
- if (currentOffset + 2 >= poolContent.length) {
- // we need to resize the poolContent array because we won't have
- // enough space to write the length
- resizePoolContents(2);
- }
- currentOffset += 2;
- int length = 0;
- for (int i = 0; i < stringCharArray.length; i++) {
- char current = stringCharArray[i];
- if ((current >= 0x0001) && (current <= 0x007F)) {
- // we only need one byte: ASCII table
- writeU1(current);
- length++;
- } else
- if (current > 0x07FF) {
- // we need 3 bytes
- length += 3;
- writeU1(0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
- writeU1(0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
- writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
- } else {
- // we can be 0 or between 0x0080 and 0x07FF
- // In that case we only need 2 bytes
- length += 2;
- writeU1(0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
- writeU1(0x80 | (current & 0x3F)); // 0x80 = 1000 0000
- }
- }
- if (length >= 65535) {
- currentOffset = savedCurrentOffset - 1;
- return -1;
- }
- stringIndex = UTF8Cache.put(stringCharArray, currentIndex++);
- // Now we know the length that we have to write in the constant pool
- // we use savedCurrentOffset to do that
- if (length > 65535) {
- return 0;
- }
- poolContent[savedCurrentOffset] = (byte) (length >> 8);
- poolContent[savedCurrentOffset + 1] = (byte) length;
- }
- index = stringCache.put(stringCharArray, currentIndex++);
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- // Write the tag first
- writeU1(StringTag);
- // Then the string index
- writeU2(stringIndex);
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding
- * nameAndType constant with nameIndex, typeIndex.
- *
- * @param nameIndex int
- * @param typeIndex int
- * @param key org.eclipse.jdt.internal.compiler.lookup.MethodBinding
- * @return <CODE>int</CODE>
- */
-public int literalIndexForMethods(int nameIndex, int typeIndex, MethodBinding key) {
- int index;
- int indexOfWellKnownMethodNameAndType;
- if ((indexOfWellKnownMethodNameAndType = indexOfWellKnownMethodNameAndType(key)) == -1) {
- // check if the entry exists
- if ((index = nameAndTypeCacheForMethods.get(key)) == -1) {
- // The entry doesn't exit yet
- index = nameAndTypeCacheForMethods.put(key, currentIndex++);
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- } else {
- if ((index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType]) == 0) {
- index = wellKnownMethodNameAndTypes[indexOfWellKnownMethodNameAndType] = currentIndex++;
- if (index > 0xFFFF){
- this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceInConstantPool(this.classFile.referenceBinding.scope.referenceType());
- }
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- }
- return index;
-}
-/**
- * This method returns the index into the constantPool corresponding to the
- * method descriptor. It can be either an interface method reference constant
- * or a method reference constant.
- *
- * @return <CODE>int</CODE>
- */
-public int literalIndexForJavaLangObjectGetClass() {
- int index;
- int nameAndTypeIndex;
- int classIndex;
- // Looking into the method ref table
- if ((index = wellKnownMethods[GETCLASS_OBJECT_METHOD]) == 0) {
- classIndex = literalIndexForJavaLangObject();
- if ((nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE]) == 0) {
- int nameIndex = literalIndex(QualifiedNamesConstants.GetClass);
- int typeIndex = literalIndex(QualifiedNamesConstants.GetClassSignature);
- nameAndTypeIndex = wellKnownMethodNameAndTypes[GETCLASS_OBJECT_METHOD_NAME_AND_TYPE] = currentIndex++;
- writeU1(NameAndTypeTag);
- writeU2(nameIndex);
- writeU2(typeIndex);
- }
- index = wellKnownMethods[GETCLASS_OBJECT_METHOD] = currentIndex++;
- // Write the method ref constant into the constant pool
- // First add the tag
- writeU1(MethodRefTag);
- // Then write the class index
- writeU2(classIndex);
- // The write the nameAndType index
- writeU2(nameAndTypeIndex);
}
return index;
}
if (UTF8Cache.get(AttributeNamesConstants.CodeName) >= constantPoolIndex) {
UTF8Cache.remove(AttributeNamesConstants.CodeName);
}
- if (UTF8Cache.get(QualifiedNamesConstants.ClinitSignature) >= constantPoolIndex) {
- UTF8Cache.remove(QualifiedNamesConstants.ClinitSignature);
+ if (UTF8Cache.get(ConstantPool.ClinitSignature) >= constantPoolIndex) {
+ UTF8Cache.remove(ConstantPool.ClinitSignature);
}
- if (UTF8Cache.get(QualifiedNamesConstants.Clinit) >= constantPoolIndex) {
- UTF8Cache.remove(QualifiedNamesConstants.Clinit);
+ if (UTF8Cache.get(ConstantPool.Clinit) >= constantPoolIndex) {
+ UTF8Cache.remove(ConstantPool.Clinit);
}
}