Search in sources :

Example 66 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 ReferenceTypeAwareAssignerTest method testSourceToTargetAssignable.

@Test
public void testSourceToTargetAssignable() throws Exception {
    defineAssignability(true, false);
    StackManipulation stackManipulation = ReferenceTypeAwareAssigner.INSTANCE.assign(source, target, Assigner.Typing.STATIC);
    assertThat(stackManipulation.isValid(), is(true));
    StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
    assertThat(size.getSizeImpact(), is(0));
    assertThat(size.getMaximalSize(), is(0));
    verifyZeroInteractions(methodVisitor);
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 67 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 ReferenceTypeAwareAssignerTest method testTargetToSourceAssignable.

@Test(expected = IllegalStateException.class)
public void testTargetToSourceAssignable() throws Exception {
    defineAssignability(false, true);
    StackManipulation stackManipulation = ReferenceTypeAwareAssigner.INSTANCE.assign(source, target, Assigner.Typing.STATIC);
    assertThat(stackManipulation.isValid(), is(false));
    stackManipulation.apply(methodVisitor, implementationContext);
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 68 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 AssignerEqualTypesOnlyTest method testAssignmentErasureNotEqual.

@Test
public void testAssignmentErasureNotEqual() throws Exception {
    StackManipulation stackManipulation = Assigner.EqualTypesOnly.ERASURE.assign(first, second, Assigner.Typing.of(dynamicallyTyped));
    assertThat(stackManipulation.isValid(), is(false));
    verify(first).asErasure();
    verifyNoMoreInteractions(first);
    verify(second).asErasure();
    verifyNoMoreInteractions(second);
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 69 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 AssignerRefusingTest method testAssignmentEqual.

@Test
public void testAssignmentEqual() throws Exception {
    StackManipulation stackManipulation = Assigner.Refusing.INSTANCE.assign(first, first, Assigner.Typing.of(dynamicallyTyped));
    assertThat(stackManipulation.isValid(), is(false));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 70 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 AssignerRefusingTest method testAssignmentNotEqual.

@Test
public void testAssignmentNotEqual() throws Exception {
    StackManipulation stackManipulation = Assigner.Refusing.INSTANCE.assign(first, second, Assigner.Typing.of(dynamicallyTyped));
    assertThat(stackManipulation.isValid(), is(false));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) 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