proguard.classfile.editor
Class ConstantPoolEditor

java.lang.Object
  extended by proguard.classfile.editor.ConstantPoolEditor

public class ConstantPoolEditor
extends java.lang.Object

This class can add constant pool entries to a given class.


Constructor Summary
ConstantPoolEditor(ProgramClass targetClass)
          Creates a new ConstantPoolEditor that will edit constants in the given target class.
 
Method Summary
 int addClassConstant(Clazz referencedClass)
          Finds or creates a ClassConstant constant pool entry for the given class.
 int addClassConstant(java.lang.String name, Clazz referencedClass)
          Finds or creates a ClassConstant constant pool entry with the given name.
 int addConstant(Constant constant)
          Adds a given constant pool entry to the end of the constant pool/
 int addDoubleConstant(double value)
          Finds or creates a DoubleConstant constant pool entry with the given value.
 int addFieldrefConstant(Clazz referencedClass, Member referencedMember)
          Finds or creates a FieldrefConstant constant pool entry for the given class and field.
 int addFieldrefConstant(int classIndex, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember)
          Finds or creates a FieldrefConstant constant pool entry with the given class constant pool entry index and name and type constant pool entry index.
 int addFieldrefConstant(int classIndex, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Member referencedMember)
          Finds or creates a FieldrefConstant constant pool entry with the given class constant pool entry index, field name, and descriptor.
 int addFieldrefConstant(java.lang.String className, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember)
          Finds or creates a FieldrefConstant constant pool entry with the given class name, field name, and descriptor.
 int addFieldrefConstant(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Member referencedMember)
          Finds or creates a FieldrefConstant constant pool entry with the given class name, field name, and descriptor.
 int addFloatConstant(float value)
          Finds or creates a FloatConstant constant pool entry with the given value.
 int addIntegerConstant(int value)
          Finds or creates a IntegerConstant constant pool entry with the given value.
 int addInterfaceMethodrefConstant(Clazz referencedClass, Member referencedMember)
          Finds or creates a InterfaceMethodrefConstant constant pool entry for the given class and method.
 int addInterfaceMethodrefConstant(int classIndex, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember)
          Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class constant pool entry index and name and type constant pool entry index.
 int addInterfaceMethodrefConstant(int classIndex, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Member referencedMember)
          Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class constant pool entry index, method name, and descriptor.
 int addInterfaceMethodrefConstant(java.lang.String className, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember)
          Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class name, method name, and descriptor.
 int addInterfaceMethodrefConstant(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Member referencedMember)
          Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class name, method name, and descriptor.
 int addLongConstant(long value)
          Finds or creates a LongConstant constant pool entry with the given value.
 int addMethodrefConstant(Clazz referencedClass, Member referencedMember)
          Finds or creates a MethodrefConstant constant pool entry for the given class and method.
 int addMethodrefConstant(int classIndex, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember)
          Finds or creates a MethodrefConstant constant pool entry with the given class constant pool entry index and name and type constant pool entry index.
 int addMethodrefConstant(int classIndex, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Member referencedMember)
          Finds or creates a MethodrefConstant constant pool entry with the given class constant pool entry index, method name, and descriptor.
 int addMethodrefConstant(java.lang.String className, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember)
          Finds or creates a MethodrefConstant constant pool entry with the given class name, method name, and descriptor.
 int addMethodrefConstant(java.lang.String className, java.lang.String name, java.lang.String descriptor, Clazz referencedClass, Member referencedMember)
          Finds or creates a MethodrefConstant constant pool entry with the given class name, method name, and descriptor.
 int addNameAndTypeConstant(java.lang.String name, java.lang.String type)
          Finds or creates a NameAndTypeConstant constant pool entry with the given name and type.
 int addStringConstant(java.lang.String string, Clazz referencedClass, Member referencedMember)
          Finds or creates a StringConstant constant pool entry with the given value.
 int addUtf8Constant(java.lang.String string)
          Finds or creates a Utf8Constant constant pool entry for the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantPoolEditor

public ConstantPoolEditor(ProgramClass targetClass)
Creates a new ConstantPoolEditor that will edit constants in the given target class.

Method Detail

addIntegerConstant

public int addIntegerConstant(int value)
Finds or creates a IntegerConstant constant pool entry with the given value.

Returns:
the constant pool index of the Utf8Constant.

addLongConstant

public int addLongConstant(long value)
Finds or creates a LongConstant constant pool entry with the given value.

Returns:
the constant pool index of the LongConstant.

addFloatConstant

public int addFloatConstant(float value)
Finds or creates a FloatConstant constant pool entry with the given value.

Returns:
the constant pool index of the FloatConstant.

addDoubleConstant

public int addDoubleConstant(double value)
Finds or creates a DoubleConstant constant pool entry with the given value.

Returns:
the constant pool index of the DoubleConstant.

addStringConstant

public int addStringConstant(java.lang.String string,
                             Clazz referencedClass,
                             Member referencedMember)
Finds or creates a StringConstant constant pool entry with the given value.

Returns:
the constant pool index of the StringConstant.

addFieldrefConstant

public int addFieldrefConstant(Clazz referencedClass,
                               Member referencedMember)
Finds or creates a FieldrefConstant constant pool entry for the given class and field.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(java.lang.String className,
                               java.lang.String name,
                               java.lang.String descriptor,
                               Clazz referencedClass,
                               Member referencedMember)
Finds or creates a FieldrefConstant constant pool entry with the given class name, field name, and descriptor.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(java.lang.String className,
                               int nameAndTypeIndex,
                               Clazz referencedClass,
                               Member referencedMember)
Finds or creates a FieldrefConstant constant pool entry with the given class name, field name, and descriptor.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(int classIndex,
                               java.lang.String name,
                               java.lang.String descriptor,
                               Clazz referencedClass,
                               Member referencedMember)
Finds or creates a FieldrefConstant constant pool entry with the given class constant pool entry index, field name, and descriptor.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(int classIndex,
                               int nameAndTypeIndex,
                               Clazz referencedClass,
                               Member referencedMember)
Finds or creates a FieldrefConstant constant pool entry with the given class constant pool entry index and name and type constant pool entry index.

Returns:
the constant pool index of the FieldrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(java.lang.String className,
                                         java.lang.String name,
                                         java.lang.String descriptor,
                                         Clazz referencedClass,
                                         Member referencedMember)
Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class name, method name, and descriptor.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(java.lang.String className,
                                         int nameAndTypeIndex,
                                         Clazz referencedClass,
                                         Member referencedMember)
Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class name, method name, and descriptor.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(Clazz referencedClass,
                                         Member referencedMember)
Finds or creates a InterfaceMethodrefConstant constant pool entry for the given class and method.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(int classIndex,
                                         java.lang.String name,
                                         java.lang.String descriptor,
                                         Clazz referencedClass,
                                         Member referencedMember)
Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class constant pool entry index, method name, and descriptor.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(int classIndex,
                                         int nameAndTypeIndex,
                                         Clazz referencedClass,
                                         Member referencedMember)
Finds or creates a InterfaceMethodrefConstant constant pool entry with the given class constant pool entry index and name and type constant pool entry index.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(Clazz referencedClass,
                                Member referencedMember)
Finds or creates a MethodrefConstant constant pool entry for the given class and method.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(java.lang.String className,
                                java.lang.String name,
                                java.lang.String descriptor,
                                Clazz referencedClass,
                                Member referencedMember)
Finds or creates a MethodrefConstant constant pool entry with the given class name, method name, and descriptor.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(java.lang.String className,
                                int nameAndTypeIndex,
                                Clazz referencedClass,
                                Member referencedMember)
Finds or creates a MethodrefConstant constant pool entry with the given class name, method name, and descriptor.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(int classIndex,
                                java.lang.String name,
                                java.lang.String descriptor,
                                Clazz referencedClass,
                                Member referencedMember)
Finds or creates a MethodrefConstant constant pool entry with the given class constant pool entry index, method name, and descriptor.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(int classIndex,
                                int nameAndTypeIndex,
                                Clazz referencedClass,
                                Member referencedMember)
Finds or creates a MethodrefConstant constant pool entry with the given class constant pool entry index and name and type constant pool entry index.

Returns:
the constant pool index of the MethodrefConstant.

addClassConstant

public int addClassConstant(Clazz referencedClass)
Finds or creates a ClassConstant constant pool entry for the given class.

Returns:
the constant pool index of the ClassConstant.

addClassConstant

public int addClassConstant(java.lang.String name,
                            Clazz referencedClass)
Finds or creates a ClassConstant constant pool entry with the given name.

Returns:
the constant pool index of the ClassConstant.

addNameAndTypeConstant

public int addNameAndTypeConstant(java.lang.String name,
                                  java.lang.String type)
Finds or creates a NameAndTypeConstant constant pool entry with the given name and type.

Returns:
the constant pool index of the NameAndTypeConstant.

addUtf8Constant

public int addUtf8Constant(java.lang.String string)
Finds or creates a Utf8Constant constant pool entry for the given string.

Returns:
the constant pool index of the Utf8Constant.

addConstant

public int addConstant(Constant constant)
Adds a given constant pool entry to the end of the constant pool/

Returns:
the constant pool index for the added entry.