use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethodDynamic.
@Test
public void testGenericMethodDynamic() throws Exception {
TypeDescription genericErasure = mock(TypeDescription.class);
when(methodReturnType.asErasure()).thenReturn(genericErasure);
when(declaredMethod.isBootstrap()).thenReturn(true);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).dynamic(FOO, otherType, Collections.<TypeDescription>emptyList(), Collections.emptyList());
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is(MethodInvocation.invoke(declaredMethod).dynamic(FOO, otherType, Collections.<TypeDescription>emptyList(), Collections.emptyList())));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethod.
@Test
public void testGenericMethod() throws Exception {
TypeDescription genericErasure = mock(TypeDescription.class);
when(methodReturnType.asErasure()).thenReturn(genericErasure);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription);
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is((StackManipulation) new MethodInvocation.OfGenericMethod(genericErasure, MethodInvocation.invoke(declaredMethod))));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class FieldAccessOtherTest method testGenericFieldAccessGetterEqualErasure.
@Test
public void testGenericFieldAccessGetterEqualErasure() throws Exception {
TypeDescription declaredErasure = mock(TypeDescription.class);
when(genericType.asErasure()).thenReturn(declaredErasure);
when(declaredType.asErasure()).thenReturn(declaredErasure);
StackManipulation stackManipulation = FieldAccess.forField(genericField).read();
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is(FieldAccess.forField(fieldDescription).read()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TypeVariableSourceVisitorNoOpTest method testVisitType.
@Test
public void testVisitType() throws Exception {
TypeDescription typeDescription = mock(TypeDescription.class);
MatcherAssert.assertThat(TypeVariableSource.Visitor.NoOp.INSTANCE.onType(typeDescription), is((TypeVariableSource) typeDescription));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class ClassInjectorUsingInstrumentationTest method testSystemInjection.
@Test
@AgentAttachmentRule.Enforce
public void testSystemInjection() throws Exception {
ClassInjector classInjector = ClassInjector.UsingInstrumentation.of(folder, ClassInjector.UsingInstrumentation.Target.SYSTEM, ByteBuddyAgent.install());
String name = BAR + RandomString.make();
DynamicType dynamicType = new ByteBuddy().subclass(Object.class).name(name).make();
Map<TypeDescription, Class<?>> types = classInjector.inject(Collections.singletonMap(dynamicType.getTypeDescription(), dynamicType.getBytes()));
assertThat(types.size(), is(1));
assertThat(types.get(dynamicType.getTypeDescription()).getName(), is(name));
assertThat(types.get(dynamicType.getTypeDescription()).getClassLoader(), is(ClassLoader.getSystemClassLoader()));
}
Aggregations