use of net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testMultipleAmbiguousClassInheritance.
@Test
public void testMultipleAmbiguousClassInheritance() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(AmbiguousInterfaceBase.ClassTarget.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 1));
MethodDescription first = typeDescription.getInterfaces().filter(erasure(InterfaceBase.class)).getOnly().getDeclaredMethods().filter(isMethod()).getOnly();
MethodDescription second = typeDescription.getInterfaces().filter(erasure(AmbiguousInterfaceBase.class)).getOnly().getDeclaredMethods().filter(isMethod()).getOnly();
MethodGraph.Node node = methodGraph.locate(first.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.AMBIGUOUS));
assertThat(node.getMethodTypes().size(), is(1));
assertThat(node.getMethodTypes().contains(first.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(second.asTypeToken()), is(true));
assertThat(node.getRepresentative(), is(first));
assertThat(node.getRepresentative(), not(second));
assertThat(node.getVisibility(), is(first.getVisibility()));
assertThat(node, is(methodGraph.locate(second.asSignatureToken())));
MethodGraph.Node firstBaseNode = methodGraph.getInterfaceGraph(new TypeDescription.ForLoadedType(InterfaceBase.class)).locate(first.asSignatureToken());
assertThat(node, not(firstBaseNode));
assertThat(firstBaseNode.getRepresentative(), is(first));
MethodGraph.Node secondBaseNode = methodGraph.getInterfaceGraph(new TypeDescription.ForLoadedType(InterfaceBase.class)).locate(second.asSignatureToken());
assertThat(node, not(secondBaseNode));
assertThat(secondBaseNode.getRepresentative(), is(first));
}
use of net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testTypeVariableInterfaceBridge.
@Test
@JavaVersionRule.Enforce(8)
public void testTypeVariableInterfaceBridge() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(Class.forName(TYPE_VARIABLE_INTERFACE_BRIDGE));
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription methodDescription = typeDescription.getDeclaredMethods().filter(takesArguments(String.class)).getOnly();
MethodGraph.Node node = methodGraph.locate(methodDescription.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getRepresentative(), is(methodDescription));
assertThat(node.getMethodTypes().size(), is(2));
assertThat(node.getMethodTypes().contains(methodDescription.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(typeDescription.getDeclaredMethods().filter(takesArguments(Object.class)).getOnly().asTypeToken()), is(true));
assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
use of net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testDominantInterfaceInheritanceRight.
@Test
public void testDominantInterfaceInheritanceRight() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(AmbiguousInterfaceBase.DominantInterfaceTargetRight.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription methodDescription = new TypeDescription.ForLoadedType(AmbiguousInterfaceBase.DominantIntermediate.class).getDeclaredMethods().getOnly();
MethodGraph.Node node = methodGraph.locate(methodDescription.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getMethodTypes().size(), is(1));
assertThat(node.getMethodTypes().contains(methodDescription.asTypeToken()), is(true));
assertThat(node.getRepresentative(), is(methodDescription));
assertThat(node.getVisibility(), is(methodDescription.getVisibility()));
}
use of net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testDominantClassInheritance.
@Test
public void testDominantClassInheritance() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(AmbiguousInterfaceBase.DominantClassTarget.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 1));
MethodDescription methodDescription = new TypeDescription.ForLoadedType(AmbiguousInterfaceBase.DominantIntermediate.class).getDeclaredMethods().getOnly();
MethodGraph.Node node = methodGraph.locate(methodDescription.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getMethodTypes().size(), is(1));
assertThat(node.getMethodTypes().contains(methodDescription.asTypeToken()), is(true));
assertThat(node.getRepresentative(), is(methodDescription));
assertThat(node.getVisibility(), is(methodDescription.getVisibility()));
}
use of net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testDiamondInheritanceInterface.
@Test
public void testDiamondInheritanceInterface() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericDiamondInterfaceBase.Inner.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription diamondOverride = typeDescription.getInterfaces().get(0).getDeclaredMethods().getOnly();
MethodDescription explicitOverride = typeDescription.getInterfaces().get(1).getDeclaredMethods().getOnly();
MethodGraph.Node node = methodGraph.locate(diamondOverride.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.AMBIGUOUS));
assertThat(methodGraph.locate(explicitOverride.asDefined().asSignatureToken()), is(node));
assertThat(node.getMethodTypes().size(), is(2));
assertThat(node.getMethodTypes().contains(diamondOverride.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(explicitOverride.asDefined().asTypeToken()), is(true));
assertThat(node.getVisibility(), is(explicitOverride.getVisibility()));
}
Aggregations