use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testDuplicateNameClass.
@Test
public void testDuplicateNameClass() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(DuplicateNameClass.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 2));
MethodDescription objectMethod = typeDescription.getDeclaredMethods().filter(takesArguments(Object.class)).getOnly();
MethodGraph.Node objectNode = methodGraph.locate(objectMethod.asSignatureToken());
assertThat(objectNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(objectNode.getRepresentative(), is(objectMethod));
assertThat(objectNode.getMethodTypes().size(), is(1));
assertThat(objectNode.getMethodTypes().contains(objectMethod.asTypeToken()), is(true));
assertThat(objectNode.getVisibility(), is(objectMethod.getVisibility()));
MethodDescription voidMethod = typeDescription.getDeclaredMethods().filter(takesArguments(Integer.class)).getOnly();
MethodGraph.Node voidNode = methodGraph.locate(voidMethod.asSignatureToken());
assertThat(voidNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(voidNode.getRepresentative(), is(voidMethod));
assertThat(voidNode.getMethodTypes().size(), is(1));
assertThat(voidNode.getMethodTypes().contains(voidMethod.asTypeToken()), is(true));
assertThat(voidNode.getVisibility(), is(voidMethod.getVisibility()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testGenericNonOverriddenInterfaceExtension.
@Test
public void testGenericNonOverriddenInterfaceExtension() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericNonOverriddenInterfaceBase.InnerClass.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 1));
MethodDescription methodDescription = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(isMethod()).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(methodDescription.asDefined().asTypeToken()), is(true));
assertThat(node, is(methodGraph.getInterfaceGraph(new TypeDescription.ForLoadedType(GenericNonOverriddenInterfaceBase.class)).locate(methodDescription.asSignatureToken())));
assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testMethodConvergenceVisibilityTarget.
@Test
public void testMethodConvergenceVisibilityTarget() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(MethodConvergenceVisibilityBridgeTarget.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 1));
MethodDescription genericMethod = typeDescription.getSuperClass().getSuperClass().getDeclaredMethods().filter(isMethod().and(definedMethod(takesArguments(Object.class)))).getOnly();
MethodDescription nonGenericMethod = typeDescription.getSuperClass().getSuperClass().getDeclaredMethods().filter(isMethod().and(definedMethod(takesArguments(Void.class)))).getOnly();
MethodGraph.Node node = methodGraph.locate(genericMethod.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.VISIBLE));
assertThat(node, is(methodGraph.locate(nonGenericMethod.asSignatureToken())));
assertThat(node.getMethodTypes().size(), is(2));
assertThat(node.getMethodTypes().contains(genericMethod.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(genericMethod.asDefined().asTypeToken()), is(true));
assertThat(node.getRepresentative(), is((MethodDescription) typeDescription.getSuperClass().getDeclaredMethods().filter(isMethod().and(ElementMatchers.not(isBridge()))).getOnly()));
assertThat(node.getVisibility(), is(genericMethod.getVisibility()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testDuplicateNameGenericInterfaceImplementation.
@Test
public void testDuplicateNameGenericInterfaceImplementation() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(DuplicateNameGenericInterface.InnerClass.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 3));
MethodDescription objectMethod = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(takesArguments(String.class)).getOnly();
MethodGraph.Node objectNode = methodGraph.locate(objectMethod.asSignatureToken());
assertThat(objectNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(objectNode.getRepresentative(), is(objectMethod));
assertThat(objectNode.getMethodTypes().size(), is(2));
assertThat(objectNode.getMethodTypes().contains(objectMethod.asTypeToken()), is(true));
assertThat(objectNode.getMethodTypes().contains(objectMethod.asDefined().asTypeToken()), is(true));
assertThat(objectNode.getVisibility(), is(objectMethod.getVisibility()));
MethodDescription integerMethod = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(takesArguments(Integer.class)).getOnly();
MethodGraph.Node integerNode = methodGraph.locate(integerMethod.asSignatureToken());
assertThat(integerNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(integerNode.getRepresentative(), is(integerMethod));
assertThat(integerNode.getMethodTypes().size(), is(1));
assertThat(integerNode.getMethodTypes().contains(integerMethod.asTypeToken()), is(true));
assertThat(integerNode.getMethodTypes().contains(integerMethod.asDefined().asTypeToken()), is(true));
assertThat(integerNode.getVisibility(), is(integerMethod.getVisibility()));
MethodDescription voidMethod = typeDescription.getDeclaredMethods().filter(takesArguments(Void.class)).getOnly();
MethodGraph.Node voidNode = methodGraph.locate(voidMethod.asSignatureToken());
assertThat(voidNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(voidNode.getRepresentative(), is(voidMethod));
assertThat(voidNode.getMethodTypes().size(), is(1));
assertThat(voidNode.getMethodTypes().contains(voidMethod.asTypeToken()), is(true));
assertThat(voidNode.getVisibility(), is(voidMethod.getVisibility()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testGenericNonOverriddenInterfaceImplementation.
@Test
public void testGenericNonOverriddenInterfaceImplementation() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericNonOverriddenInterfaceBase.InnerInterface.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription methodDescription = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(isMethod()).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(methodDescription.asDefined().asTypeToken()), is(true));
assertThat(node, is(methodGraph.getInterfaceGraph(new TypeDescription.ForLoadedType(GenericNonOverriddenInterfaceBase.class)).locate(methodDescription.asSignatureToken())));
assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
Aggregations