use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodVariableAccessOtherTest method testIncrement.
@Test
public void testIncrement() throws Exception {
StackManipulation stackManipulation = MethodVariableAccess.INTEGER.increment(4, 1);
assertThat(stackManipulation.isValid(), is(true));
MethodVisitor methodVisitor = mock(MethodVisitor.class);
Implementation.Context implementationContext = mock(Implementation.Context.class);
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(0));
assertThat(size.getMaximalSize(), is(0));
verify(methodVisitor).visitIincInsn(4, 1);
verifyNoMoreInteractions(methodVisitor);
verifyZeroInteractions(implementationContext);
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodVariableAccessTest method testStoring.
@Test
public void testStoring() throws Exception {
StackManipulation stackManipulation = MethodVariableAccess.of(typeDefinition).storeAt(4);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(this.size));
assertThat(size.getMaximalSize(), is(this.size));
verify(methodVisitor).visitVarInsn(writeCode, 4);
verifyNoMoreInteractions(methodVisitor);
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodVariableAccessTest method testLoading.
@Test
public void testLoading() throws Exception {
StackManipulation stackManipulation = MethodVariableAccess.of(typeDefinition).loadFrom(4);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(this.size));
assertThat(size.getMaximalSize(), is(this.size));
verify(methodVisitor).visitVarInsn(readCode, 4);
verifyNoMoreInteractions(methodVisitor);
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class PrimitiveUnboxingDelegateDirectTest method testTrivialBoxing.
@Test
public void testTrivialBoxing() throws Exception {
StackManipulation stackManipulation = PrimitiveUnboxingDelegate.forReferenceType(wrapperTypeDescription).assignUnboxedTo(primitiveTypeDescription, chainedAssigner, Assigner.Typing.STATIC);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(sizeChange));
assertThat(size.getMaximalSize(), is(sizeChange));
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(wrapperType), unboxingMethodName, unboxingMethodDescriptor, false);
verifyNoMoreInteractions(methodVisitor);
verifyZeroInteractions(chainedAssigner);
verifyZeroInteractions(this.stackManipulation);
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class PrimitiveUnboxingDelegateWideningTest method testTrivialBoxing.
@Test
public void testTrivialBoxing() throws Exception {
StackManipulation stackManipulation = PrimitiveUnboxingDelegate.forReferenceType(referenceTypeDescription).assignUnboxedTo(primitiveTypeDescription, chainedAssigner, Assigner.Typing.STATIC);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(sizeChange));
assertThat(size.getMaximalSize(), is(interimMaximum));
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(referenceType), unboxingMethodName, unboxingMethodDescriptor, false);
verify(methodVisitor).visitInsn(wideningOpcode);
verifyNoMoreInteractions(methodVisitor);
}
Aggregations