Search in sources :

Example 66 with StackManipulation

use of 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 67 with StackManipulation

use of 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 68 with StackManipulation

use of 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 69 with StackManipulation

use of 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)

Example 70 with StackManipulation

use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.

the class PrimitiveTypeAwareAssignerImplicitUnboxingTest method testImplicitUnboxingAssignment.

@Test
public void testImplicitUnboxingAssignment() {
    StackManipulation stackManipulation = primitiveAssigner.assign(source, target, Assigner.Typing.DYNAMIC);
    assertThat(stackManipulation.isValid(), is(assignable));
    verify(chainedStackManipulation).isValid();
    verifyNoMoreInteractions(chainedStackManipulation);
    verify(source, atLeast(0)).represents(any(Class.class));
    verify(source, atLeast(1)).isPrimitive();
    verify(source).asGenericType();
    verifyNoMoreInteractions(source);
    verify(target, atLeast(0)).represents(any(Class.class));
    verify(target, atLeast(1)).isPrimitive();
    verifyNoMoreInteractions(target);
    verify(chainedAssigner).assign(source, new TypeDescription.Generic.OfNonGenericType.ForLoadedType(wrapperType), Assigner.Typing.DYNAMIC);
    verifyNoMoreInteractions(chainedAssigner);
}
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)92 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 MethodDescription (net.bytebuddy.description.method.MethodDescription)4 ForLoadedType (net.bytebuddy.description.type.TypeDescription.ForLoadedType)4 Goto (org.curioswitch.common.protobuf.json.bytebuddy.Goto)4 MethodVisitor (org.objectweb.asm.MethodVisitor)4 ArrayList (java.util.ArrayList)3 Label (net.bytebuddy.jar.asm.Label)3 SetJumpTargetLabel (org.curioswitch.common.protobuf.json.bytebuddy.SetJumpTargetLabel)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 IfTrue (org.curioswitch.common.protobuf.json.bytebuddy.IfTrue)2