org.testifyproject.bytebuddy.implementation.bytecode.constant.JavaConstantValue Maven / Gradle / Ivy
The newest version!
package org.testifyproject.bytebuddy.implementation.bytecode.constant;
import lombok.EqualsAndHashCode;
import org.testifyproject.bytebuddy.implementation.Implementation;
import org.testifyproject.bytebuddy.implementation.bytecode.StackManipulation;
import org.testifyproject.bytebuddy.implementation.bytecode.StackSize;
import org.testifyproject.bytebuddy.utility.JavaConstant;
import org.testifyproject.bytebuddy.jar.asm.MethodVisitor;
/**
* A constant representing a {@link JavaConstant}.
*/
@EqualsAndHashCode
public class JavaConstantValue implements StackManipulation {
/**
* The instance to load onto the operand stack.
*/
private final JavaConstant javaConstant;
/**
* Creates a constant pool value representing a {@link JavaConstant}.
*
* @param javaConstant The instance to load onto the operand stack.
*/
public JavaConstantValue(JavaConstant javaConstant) {
this.javaConstant = javaConstant;
}
@Override
public boolean isValid() {
return true;
}
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) {
methodVisitor.visitLdcInsn(javaConstant.asConstantPoolValue());
return StackSize.SINGLE.toIncreasingSize();
}
}