Search in sources :

Example 36 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 FloatConstantTest method testBiPush.

@Test
public void testBiPush() throws Exception {
    StackManipulation floatConstant = FloatConstant.forValue(value);
    assertThat(floatConstant.isValid(), is(true));
    StackManipulation.Size size = floatConstant.apply(methodVisitor, implementationContext);
    assertThat(size.getSizeImpact(), is(1));
    assertThat(size.getMaximalSize(), is(1));
    verify(methodVisitor).visitLdcInsn(value);
    verifyNoMoreInteractions(methodVisitor);
    verifyZeroInteractions(implementationContext);
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 37 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 JavaConstantValueTest method testMethodHandle.

@Test
public void testMethodHandle() throws Exception {
    when(javaConstant.asConstantPoolValue()).thenReturn(FOO);
    StackManipulation stackManipulation = new JavaConstantValue(javaConstant);
    StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
    assertThat(size.getSizeImpact(), is(1));
    assertThat(size.getMaximalSize(), is(1));
    verify(javaConstant).asConstantPoolValue();
    verifyNoMoreInteractions(javaConstant);
    verify(methodVisitor).visitLdcInsn(FOO);
    verifyNoMoreInteractions(methodVisitor);
    verifyZeroInteractions(implementationContext);
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 38 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 LongConstantTest method testBiPush.

@Test
public void testBiPush() throws Exception {
    StackManipulation longConstant = LongConstant.forValue(value);
    assertThat(longConstant.isValid(), is(true));
    StackManipulation.Size size = longConstant.apply(methodVisitor, implementationContext);
    assertThat(size.getSizeImpact(), is(2));
    assertThat(size.getMaximalSize(), is(2));
    verify(methodVisitor).visitLdcInsn(value);
    verifyNoMoreInteractions(methodVisitor);
    verifyZeroInteractions(implementationContext);
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 39 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 FieldAccessOtherTest method testEnumerationDescriptionWithIllegalName.

@Test
public void testEnumerationDescriptionWithIllegalName() throws Exception {
    when(fieldDescription.isPublic()).thenReturn(true);
    when(fieldDescription.isStatic()).thenReturn(true);
    when(fieldDescription.isEnum()).thenReturn(true);
    when(fieldDescription.getActualName()).thenReturn(BAR);
    StackManipulation stackManipulation = FieldAccess.forEnumeration(enumerationDescription);
    assertThat(stackManipulation.isValid(), is(false));
}
Also used : StackManipulation(net.bytebuddy.implementation.bytecode.StackManipulation) Test(org.junit.Test)

Example 40 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 FieldAccessOtherTest method testEnumerationDescriptionWithIllegalVisibility.

@Test
public void testEnumerationDescriptionWithIllegalVisibility() throws Exception {
    when(fieldDescription.isPublic()).thenReturn(false);
    when(fieldDescription.isStatic()).thenReturn(true);
    when(fieldDescription.isEnum()).thenReturn(true);
    when(fieldDescription.getActualName()).thenReturn(FOO);
    StackManipulation stackManipulation = FieldAccess.forEnumeration(enumerationDescription);
    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