public class ConstantAdder extends java.lang.Object implements ConstantVisitor
ConstantVisitor
adds all constants that it visits to the constant pool of a given
target class.
Bootstrap methods attributes are automatically updated for invokedynamic constants.
Constructor and Description |
---|
ConstantAdder(ProgramClass targetClass)
Creates a new ConstantAdder that will copy constants into the given target class.
|
Modifier and Type | Method and Description |
---|---|
int |
addConstant(Clazz clazz,
Constant constant)
Adds a copy of the given constant in the given class and returns its index.
|
int |
addConstant(Clazz clazz,
int constantIndex)
Adds a copy of the specified constant in the given class and returns its index.
|
int |
getConstantIndex()
Returns the index of the most recently created constant in the constant pool of the target
class.
|
void |
visitClassConstant(Clazz clazz,
ClassConstant classConstant) |
void |
visitDoubleConstant(Clazz clazz,
DoubleConstant doubleConstant) |
void |
visitDynamicConstant(Clazz clazz,
DynamicConstant dynamicConstant) |
void |
visitFieldrefConstant(Clazz clazz,
FieldrefConstant fieldrefConstant) |
void |
visitFloatConstant(Clazz clazz,
FloatConstant floatConstant) |
void |
visitIntegerConstant(Clazz clazz,
IntegerConstant integerConstant) |
void |
visitInterfaceMethodrefConstant(Clazz clazz,
InterfaceMethodrefConstant interfaceMethodrefConstant) |
void |
visitInvokeDynamicConstant(Clazz clazz,
InvokeDynamicConstant invokeDynamicConstant) |
void |
visitLongConstant(Clazz clazz,
LongConstant longConstant) |
void |
visitMethodHandleConstant(Clazz clazz,
MethodHandleConstant methodHandleConstant) |
void |
visitMethodrefConstant(Clazz clazz,
MethodrefConstant methodrefConstant) |
void |
visitMethodTypeConstant(Clazz clazz,
MethodTypeConstant methodTypeConstant) |
void |
visitModuleConstant(Clazz clazz,
ModuleConstant moduleConstant) |
void |
visitNameAndTypeConstant(Clazz clazz,
NameAndTypeConstant nameAndTypeConstant) |
void |
visitPackageConstant(Clazz clazz,
PackageConstant packageConstant) |
void |
visitPrimitiveArrayConstant(Clazz clazz,
PrimitiveArrayConstant primitiveArrayConstant) |
void |
visitStringConstant(Clazz clazz,
StringConstant stringConstant) |
void |
visitUtf8Constant(Clazz clazz,
Utf8Constant utf8Constant) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
visitAnyConstant, visitAnyMethodrefConstant, visitAnyRefConstant
public ConstantAdder(ProgramClass targetClass)
public int addConstant(Clazz clazz, int constantIndex)
public int addConstant(Clazz clazz, Constant constant)
public int getConstantIndex()
public void visitIntegerConstant(Clazz clazz, IntegerConstant integerConstant)
visitIntegerConstant
in interface ConstantVisitor
public void visitLongConstant(Clazz clazz, LongConstant longConstant)
visitLongConstant
in interface ConstantVisitor
public void visitFloatConstant(Clazz clazz, FloatConstant floatConstant)
visitFloatConstant
in interface ConstantVisitor
public void visitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant)
visitDoubleConstant
in interface ConstantVisitor
public void visitPrimitiveArrayConstant(Clazz clazz, PrimitiveArrayConstant primitiveArrayConstant)
visitPrimitiveArrayConstant
in interface ConstantVisitor
public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
visitStringConstant
in interface ConstantVisitor
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant)
visitUtf8Constant
in interface ConstantVisitor
public void visitDynamicConstant(Clazz clazz, DynamicConstant dynamicConstant)
visitDynamicConstant
in interface ConstantVisitor
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
visitInvokeDynamicConstant
in interface ConstantVisitor
public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant)
visitMethodHandleConstant
in interface ConstantVisitor
public void visitModuleConstant(Clazz clazz, ModuleConstant moduleConstant)
visitModuleConstant
in interface ConstantVisitor
public void visitPackageConstant(Clazz clazz, PackageConstant packageConstant)
visitPackageConstant
in interface ConstantVisitor
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
visitFieldrefConstant
in interface ConstantVisitor
public void visitInterfaceMethodrefConstant(Clazz clazz, InterfaceMethodrefConstant interfaceMethodrefConstant)
visitInterfaceMethodrefConstant
in interface ConstantVisitor
public void visitMethodrefConstant(Clazz clazz, MethodrefConstant methodrefConstant)
visitMethodrefConstant
in interface ConstantVisitor
public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
visitClassConstant
in interface ConstantVisitor
public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
visitMethodTypeConstant
in interface ConstantVisitor
public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant)
visitNameAndTypeConstant
in interface ConstantVisitor