FieldList<FieldDescription.InDefinedShape> candidates = resolution.resolve().getDeclaredFields().filter(strict ? ElementMatchers.<FieldDescription>named(internalName).and(hasDescriptor(descriptor)) : ElementMatchers.<FieldDescription>failSafe(named(internalName).and(hasDescriptor(descriptor)))); if (!candidates.isEmpty()) { Replacement.Binding binding = replacement.bind(candidates.getOnly(), opcode == Opcodes.PUTFIELD || opcode == Opcodes.PUTSTATIC);
candidates = resolution.resolve().getDeclaredMethods().filter(strict ? ElementMatchers.<MethodDescription>isConstructor().and(hasDescriptor(descriptor)) : ElementMatchers.<MethodDescription>failSafe(isConstructor().and(hasDescriptor(descriptor)))); } else if (opcode == Opcodes.INVOKESTATIC || opcode == Opcodes.INVOKESPECIAL) { candidates = resolution.resolve().getDeclaredMethods().filter(strict ? ElementMatchers.<MethodDescription>named(internalName).and(hasDescriptor(descriptor)) : ElementMatchers.<MethodDescription>failSafe(named(internalName).and(hasDescriptor(descriptor)))); } else { // Invokevirtual and invokeinterface can represent a private, non-static method from Java 11. candidates = resolution.resolve().getDeclaredMethods().filter(strict ? ElementMatchers.<MethodDescription>isPrivate().and(not(isStatic())).and(named(internalName).and(hasDescriptor(descriptor))) : ElementMatchers.<MethodDescription>failSafe(isPrivate().<MethodDescription>and(not(isStatic())).and(named(internalName).and(hasDescriptor(descriptor))))); if (candidates.isEmpty()) { candidates = methodGraphCompiler.compile(resolution.resolve(), instrumentedType).listNodes().asMethodList().filter(strict ? ElementMatchers.<MethodDescription>named(internalName).and(hasDescriptor(descriptor)) : ElementMatchers.<MethodDescription>failSafe(named(internalName).and(hasDescriptor(descriptor))));
/** * {@inheritDoc} */ public MethodGraph.Linked compile(TypeDefinition typeDefinition, TypeDescription viewPoint) { LinkedHashMap<MethodDescription.SignatureToken, MethodGraph.Node> nodes = new LinkedHashMap<MethodDescription.SignatureToken, MethodGraph.Node>(); for (MethodDescription methodDescription : typeDefinition.getDeclaredMethods() .filter( // ignores all methods which refer to unknown types failSafe( isVirtual() .and(not(isBridge())) .and(isVisibleTo(viewPoint)) .and(hasParameters(whereNone(hasType(not(isVisibleTo(viewPoint)))))) ) ) ) { nodes.put(methodDescription.asSignatureToken(), new MethodGraph.Node.Simple(methodDescription)); } return new MethodGraph.Linked.Delegation(new MethodGraph.Simple(nodes), MethodGraph.Empty.INSTANCE, Collections.<TypeDescription, MethodGraph>emptyMap()); } }