Search in sources :

Example 86 with StackManipulation

use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.

the class MethodInvocationGenericTest method testGenericMethodErasureEqual.

@Test
public void testGenericMethodErasureEqual() throws Exception {
    when(methodReturnType.asErasure()).thenReturn(declaredErasure);
    StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription);
    assertThat(stackManipulation.isValid(), is(true));
    assertThat(stackManipulation, is((StackManipulation) MethodInvocation.invoke(declaredMethod)));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 87 with StackManipulation

use of org.apache.beam.vendor.bytebuddy.v1_11_0.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)));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 88 with StackManipulation

use of org.apache.beam.vendor.bytebuddy.v1_11_0.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))));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) TypeDescription(net.bytebuddy.description.type.TypeDescription) Test(org.junit.Test)

Example 89 with StackManipulation

use of org.apache.beam.vendor.bytebuddy.v1_11_0.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));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) TypeDescription(net.bytebuddy.description.type.TypeDescription) Test(org.junit.Test)

Example 90 with StackManipulation

use of org.apache.beam.vendor.bytebuddy.v1_11_0.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))));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) TypeDescription(net.bytebuddy.description.type.TypeDescription) Test(org.junit.Test)

Aggregations

StackManipulation (net.bytebuddy.implementation.bytecode.StackManipulation)93 Test (org.junit.Test)85 TypeDescription (net.bytebuddy.description.type.TypeDescription)18 Implementation (net.bytebuddy.implementation.Implementation)5 Assigner (net.bytebuddy.implementation.bytecode.assign.Assigner)5 Goto (org.curioswitch.common.protobuf.json.bytebuddy.Goto)5 MethodDescription (net.bytebuddy.description.method.MethodDescription)4 ForLoadedType (net.bytebuddy.description.type.TypeDescription.ForLoadedType)4 Label (net.bytebuddy.jar.asm.Label)4 SetJumpTargetLabel (org.curioswitch.common.protobuf.json.bytebuddy.SetJumpTargetLabel)4 MethodVisitor (org.objectweb.asm.MethodVisitor)4 ArrayList (java.util.ArrayList)3 IfTrue (org.curioswitch.common.protobuf.json.bytebuddy.IfTrue)3 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)2 Type (java.lang.reflect.Type)2 FieldDescription (net.bytebuddy.description.field.FieldDescription)2 JavaConstant (net.bytebuddy.utility.JavaConstant)2 ForLoadedType (org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription.ForLoadedType)2 DynamicType (org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.dynamic.DynamicType)2 StackManipulation (org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation)2