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 given classes.


Constructor Summary
ConstantPoolEditor()
           
 
Method Summary
 int addClassConstant(ProgramClass programClass, Clazz referencedClass)
          Finds or creates a ClassConstant constant pool entry for the given class, in the given class.
 int addClassConstant(ProgramClass programClass, java.lang.String name, Clazz referencedClass)
          Finds or creates a ClassConstant constant pool entry with the given name, in the given class.
 int addConstant(ProgramClass programClass, Constant constant)
          Adds a given constant pool entry to the end of the constant pool in the given class.
 int addDoubleConstant(ProgramClass programClass, double value)
          Finds or creates a DoubleConstant constant pool entry with the given value, in the given class.
 int addFieldrefConstant(ProgramClass programClass, Clazz referencedClass, Member referencedMember)
          Finds or creates a FieldrefConstant constant pool entry for the given class and field, in the given class.
 int addFieldrefConstant(ProgramClass programClass, 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 the given class.
 int addFieldrefConstant(ProgramClass programClass, 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, in the given class.
 int addFieldrefConstant(ProgramClass programClass, 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, in the given class.
 int addFieldrefConstant(ProgramClass programClass, 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, in the given class.
 int addFloatConstant(ProgramClass programClass, float value)
          Finds or creates a FloatConstant constant pool entry with the given value, in the given class.
 int addIntegerConstant(ProgramClass programClass, int value)
          Finds or creates a IntegerConstant constant pool entry with the given value, in the given class.
 int addInterfaceMethodrefConstant(ProgramClass programClass, Clazz referencedClass, Member referencedMember)
          Finds or creates a InterfaceMethodrefConstant constant pool entry for the given class and method, in the given class.
 int addInterfaceMethodrefConstant(ProgramClass programClass, 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 the given class.
 int addInterfaceMethodrefConstant(ProgramClass programClass, 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, in the given class.
 int addInterfaceMethodrefConstant(ProgramClass programClass, 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, in the given class.
 int addInterfaceMethodrefConstant(ProgramClass programClass, 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, in the given class.
 int addLongConstant(ProgramClass programClass, long value)
          Finds or creates a LongConstant constant pool entry with the given value, in the given class.
 int addMethodrefConstant(ProgramClass programClass, Clazz referencedClass, Member referencedMember)
          Finds or creates a MethodrefConstant constant pool entry for the given class and method, in the given class.
 int addMethodrefConstant(ProgramClass programClass, 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 the given class.
 int addMethodrefConstant(ProgramClass programClass, 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, in the given class.
 int addMethodrefConstant(ProgramClass programClass, 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, in the given class.
 int addMethodrefConstant(ProgramClass programClass, 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, in the given class.
 int addNameAndTypeConstant(ProgramClass programClass, java.lang.String name, java.lang.String type)
          Finds or creates a NameAndTypeConstant constant pool entry with the given name and type, in the given class.
 int addStringConstant(ProgramClass programClass, java.lang.String string, Clazz referencedClass, Member referencedMember)
          Finds or creates a StringConstant constant pool entry with the given value, in the given class.
 int addUtf8Constant(ProgramClass programClass, java.lang.String string)
          Finds or creates a Utf8Constant constant pool entry for the given string, in the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantPoolEditor

public ConstantPoolEditor()
Method Detail

addIntegerConstant

public int addIntegerConstant(ProgramClass programClass,
                              int value)
Finds or creates a IntegerConstant constant pool entry with the given value, in the given class.

Returns:
the constant pool index of the Utf8Constant.

addLongConstant

public int addLongConstant(ProgramClass programClass,
                           long value)
Finds or creates a LongConstant constant pool entry with the given value, in the given class.

Returns:
the constant pool index of the Utf8Constant.

addFloatConstant

public int addFloatConstant(ProgramClass programClass,
                            float value)
Finds or creates a FloatConstant constant pool entry with the given value, in the given class.

Returns:
the constant pool index of the Utf8Constant.

addDoubleConstant

public int addDoubleConstant(ProgramClass programClass,
                             double value)
Finds or creates a DoubleConstant constant pool entry with the given value, in the given class.

Returns:
the constant pool index of the Utf8Constant.

addStringConstant

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

Returns:
the constant pool index of the ClassConstant.

addFieldrefConstant

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

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(ProgramClass programClass,
                               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, in the given class.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(ProgramClass programClass,
                               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, in the given class.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(ProgramClass programClass,
                               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, in the given class.

Returns:
the constant pool index of the FieldrefConstant.

addFieldrefConstant

public int addFieldrefConstant(ProgramClass programClass,
                               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 the given class.

Returns:
the constant pool index of the FieldrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(ProgramClass programClass,
                                         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, in the given class.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(ProgramClass programClass,
                                         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, in the given class.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

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

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(ProgramClass programClass,
                                         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, in the given class.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addInterfaceMethodrefConstant

public int addInterfaceMethodrefConstant(ProgramClass programClass,
                                         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 the given class.

Returns:
the constant pool index of the InterfaceMethodrefConstant.

addMethodrefConstant

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

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(ProgramClass programClass,
                                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, in the given class.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(ProgramClass programClass,
                                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, in the given class.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(ProgramClass programClass,
                                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, in the given class.

Returns:
the constant pool index of the MethodrefConstant.

addMethodrefConstant

public int addMethodrefConstant(ProgramClass programClass,
                                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 the given class.

Returns:
the constant pool index of the MethodrefConstant.

addClassConstant

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

Returns:
the constant pool index of the ClassConstant.

addClassConstant

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

Returns:
the constant pool index of the ClassConstant.

addNameAndTypeConstant

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

Returns:
the constant pool index of the NameAndTypeConstant.

addUtf8Constant

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

Returns:
the constant pool index of the Utf8Constant.

addConstant

public int addConstant(ProgramClass programClass,
                       Constant constant)
Adds a given constant pool entry to the end of the constant pool in the given class.

Returns:
the constant pool index for the added entry.