/** * Finds or creates a PrimitiveArrayConstant constant pool entry with the * given values. * @return the constant pool index of the PrimitiveArrayConstant. */ public int addPrimitiveArrayConstant(Object values) { return addConstant(new PrimitiveArrayConstant(values)); }
/** * Finds or creates a PrimitiveArrayConstant constant pool entry with the * given values. * @return the constant pool index of the PrimitiveArrayConstant. */ public int addPrimitiveArrayConstant(Object values) { return addConstant(new PrimitiveArrayConstant(values)); }
/** * Finds or creates a PrimitiveArrayConstant constant pool entry with the * given values. * @return the constant pool index of the PrimitiveArrayConstant. */ public int addPrimitiveArrayConstant(Object values) { return addConstant(new PrimitiveArrayConstant(values)); }
/** * Finds or creates a Utf8Constant constant pool entry for the given string. * @return the constant pool index of the Utf8Constant. */ public int addUtf8Constant(String string) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Utf8) { Utf8Constant utf8Constant = (Utf8Constant)constant; if (utf8Constant.getString().equals(string)) { return index; } } } return addConstant(new Utf8Constant(string)); }
/** * Finds or creates a Utf8Constant constant pool entry for the given string. * @return the constant pool index of the Utf8Constant. */ public int addUtf8Constant(String string) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Utf8) { Utf8Constant utf8Constant = (Utf8Constant)constant; if (utf8Constant.getString().equals(string)) { return index; } } } return addConstant(new Utf8Constant(string)); }
/** * Finds or creates a Utf8Constant constant pool entry for the given string. * @return the constant pool index of the Utf8Constant. */ public int addUtf8Constant(String string) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Utf8) { Utf8Constant utf8Constant = (Utf8Constant)constant; if (utf8Constant.getString().equals(string)) { return index; } } } return addConstant(new Utf8Constant(string)); }
/** * Finds or creates a Utf8Constant constant pool entry for the given string. * @return the constant pool index of the Utf8Constant. */ public int addUtf8Constant(String string) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Utf8) { Utf8Constant utf8Constant = (Utf8Constant)constant; if (utf8Constant.getString().equals(string)) { return index; } } } return addConstant(new Utf8Constant(string)); }
/** * Explicitly adds a new class constant for the given class in the given * program class. */ private int addNewClassConstant(ProgramClass programClass, String className, Clazz referencedClass) { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor(programClass); int nameIndex = constantPoolEditor.addUtf8Constant(className); int classConstantIndex = constantPoolEditor.addConstant(new ClassConstant(nameIndex, referencedClass)); return classConstantIndex; } }
/** * Explicitly adds a new class constant for the given class in the given * program class. */ private int addNewClassConstant(ProgramClass programClass, String className, Clazz referencedClass) { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor(programClass); int nameIndex = constantPoolEditor.addUtf8Constant(className); int classConstantIndex = constantPoolEditor.addConstant(new ClassConstant(nameIndex, referencedClass)); return classConstantIndex; } }
/** * Explicitly adds a new class constant for the given class in the given * program class. */ private int addNewClassConstant(ProgramClass programClass, String className, Clazz referencedClass) { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor(programClass); int nameIndex = constantPoolEditor.addUtf8Constant(className); int classConstantIndex = constantPoolEditor.addConstant(new ClassConstant(nameIndex, referencedClass)); return classConstantIndex; } }
/** * Explicitly adds a new class constant for the given class in the given * program class. */ private int addNewClassConstant(ProgramClass programClass, String className, Clazz referencedClass) { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor(programClass); int nameIndex = constantPoolEditor.addUtf8Constant(className); int classConstantIndex = constantPoolEditor.addConstant(new ClassConstant(nameIndex, referencedClass)); return classConstantIndex; } }
/** * Finds or creates a FloatConstant constant pool entry with the given * value. * @return the constant pool index of the FloatConstant. */ public int addFloatConstant(float value) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Float) { FloatConstant floatConstant = (FloatConstant)constant; if (floatConstant.getValue() == value) { return index; } } } return addConstant(new FloatConstant(value)); }
/** * Finds or creates a LongConstant constant pool entry with the given value. * @return the constant pool index of the LongConstant. */ public int addLongConstant(long value) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Long) { LongConstant longConstant = (LongConstant)constant; if (longConstant.getValue() == value) { return index; } } } return addConstant(new LongConstant(value)); }
/** * Finds or creates a PackageConstant constant pool entry with the given name. * @return the constant pool index of the PackageConstant. */ public int addPackageConstant(String name) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Package) { PackageConstant packageConstant = (PackageConstant)constant; if (packageConstant.getName(targetClass).equals(name)) { return index; } } } int nameIndex = addUtf8Constant(name); return addConstant(new PackageConstant(nameIndex)); }
/** * Finds or creates a LongConstant constant pool entry with the given value. * @return the constant pool index of the LongConstant. */ public int addLongConstant(long value) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Long) { LongConstant longConstant = (LongConstant)constant; if (longConstant.getValue() == value) { return index; } } } return addConstant(new LongConstant(value)); }
/** * Finds or creates a IntegerConstant constant pool entry with the given * value. * @return the constant pool index of the Utf8Constant. */ public int addIntegerConstant(int value) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Integer) { IntegerConstant integerConstant = (IntegerConstant)constant; if (integerConstant.getValue() == value) { return index; } } } return addConstant(new IntegerConstant(value)); }
/** * Finds or creates a ClassConstant constant pool entry with the given name. * @return the constant pool index of the ClassConstant. */ public int addClassConstant(String name, Clazz referencedClass) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Class) { ClassConstant classConstant = (ClassConstant)constant; if (classConstant.getName(targetClass).equals(name)) { return index; } } } int nameIndex = addUtf8Constant(name); return addConstant(new ClassConstant(nameIndex, referencedClass)); }
/** * Finds or creates a LongConstant constant pool entry with the given value. * @return the constant pool index of the LongConstant. */ public int addLongConstant(long value) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Long) { LongConstant longConstant = (LongConstant)constant; if (longConstant.getValue() == value) { return index; } } } return addConstant(new LongConstant(value)); }
/** * Finds or creates a PackageConstant constant pool entry with the given name. * @return the constant pool index of the PackageConstant. */ public int addPackageConstant(String name) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_Package) { PackageConstant packageConstant = (PackageConstant)constant; if (packageConstant.getName(targetClass).equals(name)) { return index; } } } int nameIndex = addUtf8Constant(name); return addConstant(new PackageConstant(nameIndex)); }
/** * Finds or creates a NameAndTypeConstant constant pool entry with the given * name and type. * @return the constant pool index of the NameAndTypeConstant. */ public int addNameAndTypeConstant(String name, String type) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_NameAndType) { NameAndTypeConstant nameAndTypeConstant = (NameAndTypeConstant)constant; if (nameAndTypeConstant.getName(targetClass).equals(name) && nameAndTypeConstant.getType(targetClass).equals(type)) { return index; } } } return addConstant(new NameAndTypeConstant(addUtf8Constant(name), addUtf8Constant(type))); }