use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethodSpecialErasureEqual.
@Test
public void testGenericMethodSpecialErasureEqual() throws Exception {
when(methodReturnType.asErasure()).thenReturn(declaredErasure);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).special(targetType);
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is(MethodInvocation.invoke(declaredMethod).special(targetType)));
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethodVirtual.
@Test
public void testGenericMethodVirtual() throws Exception {
TypeDescription genericErasure = mock(TypeDescription.class);
when(methodReturnType.asErasure()).thenReturn(genericErasure);
when(genericErasure.asErasure()).thenReturn(genericErasure);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).virtual(targetType);
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is((StackManipulation) new StackManipulation.Compound(MethodInvocation.invoke(declaredMethod).virtual(targetType), TypeCasting.to(genericErasure))));
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testIllegal.
@Test
public void testIllegal() throws Exception {
TypeDescription genericErasure = mock(TypeDescription.class);
when(methodReturnType.asErasure()).thenReturn(genericErasure);
when(declaredMethod.isTypeInitializer()).thenReturn(true);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription);
assertThat(stackManipulation.isValid(), is(false));
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethodSpecial.
@Test
public void testGenericMethodSpecial() throws Exception {
TypeDescription genericErasure = mock(TypeDescription.class);
when(methodReturnType.asErasure()).thenReturn(genericErasure);
when(genericErasure.asErasure()).thenReturn(genericErasure);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).special(targetType);
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is((StackManipulation) new StackManipulation.Compound(MethodInvocation.invoke(declaredMethod).special(targetType), TypeCasting.to(genericErasure))));
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodReturnTest method testVoidReturn.
@Test
public void testVoidReturn() throws Exception {
StackManipulation stackManipulation = MethodReturn.of(typeDefinition);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(-1 * sizeChange));
assertThat(size.getMaximalSize(), is(0));
verify(methodVisitor).visitInsn(opcode);
verifyNoMoreInteractions(methodVisitor);
}
Aggregations