Search in sources :

Example 1 with TypeVariableToken

use of net.bytebuddy.description.type.TypeVariableToken in project byte-buddy by raphw.

the class MethodGraphCompilerDefaultTest method testOrphanedBridge.

@Test
public void testOrphanedBridge() throws Exception {
    MethodDescription.SignatureToken bridgeMethod = new MethodDescription.SignatureToken("foo", TypeDescription.VOID, Collections.<TypeDescription>emptyList());
    TypeDescription typeDescription = new InstrumentedType.Default("foo", Opcodes.ACC_PUBLIC, TypeDescription.Generic.OBJECT, Collections.<TypeVariableToken>emptyList(), Collections.<TypeDescription.Generic>emptyList(), Collections.<FieldDescription.Token>emptyList(), Collections.singletonList(new MethodDescription.Token("foo", Opcodes.ACC_BRIDGE, TypeDescription.Generic.VOID, Collections.<TypeDescription.Generic>emptyList())), Collections.<AnnotationDescription>emptyList(), TypeInitializer.None.INSTANCE, LoadedTypeInitializer.NoOp.INSTANCE, TypeDescription.UNDEFINED, MethodDescription.UNDEFINED, TypeDescription.UNDEFINED, Collections.<TypeDescription>emptyList(), false, false, false);
    MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
    assertThat(methodGraph.listNodes().size(), is(1 + TypeDescription.OBJECT.getDeclaredMethods().filter(ElementMatchers.isVirtual()).size()));
    MethodGraph.Node node = methodGraph.locate(bridgeMethod);
    assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
    assertThat(node.getRepresentative().asSignatureToken(), is(bridgeMethod));
    assertThat(node.getMethodTypes().size(), is(1));
    assertThat(node.getMethodTypes(), hasItem(bridgeMethod.asTypeToken()));
    assertThat(node.getVisibility(), is(Visibility.PACKAGE_PRIVATE));
}
Also used : MethodDescription(net.bytebuddy.description.method.MethodDescription) TypeDescription(net.bytebuddy.description.type.TypeDescription) TypeVariableToken(net.bytebuddy.description.type.TypeVariableToken) FieldDescription(net.bytebuddy.description.field.FieldDescription) Test(org.junit.Test)

Aggregations

FieldDescription (net.bytebuddy.description.field.FieldDescription)1 MethodDescription (net.bytebuddy.description.method.MethodDescription)1 TypeDescription (net.bytebuddy.description.type.TypeDescription)1 TypeVariableToken (net.bytebuddy.description.type.TypeVariableToken)1 Test (org.junit.Test)1