{"record":{"id":"7498412fd9181bde","repo":"elastic/elasticsearch","slug":"function-reference-s-s-d-matching-s-s-d","errorCode":null,"errorMessage":"function reference [%s::%s/%d] matching [%s, %s/%d] not found","messagePattern":"function reference \\[(.+?)::(.+?)/(.+?)\\] matching \\[(.+?), (.+?)/(.+?)\\] not found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/lang-painless/src/main/java/org/elasticsearch/painless/FunctionRef.java","lineNumber":191,"sourceCode":"\n                boolean captured = numberOfCaptures == 1;\n                PainlessMethod painlessMethod = painlessLookup.lookupPainlessMethod(\n                    typeName,\n                    true,\n                    methodName,\n                    interfaceTypeParametersSize\n                );\n\n                if (painlessMethod == null) {\n                    painlessMethod = painlessLookup.lookupPainlessMethod(\n                        typeName,\n                        false,\n                        methodName,\n                        captured ? interfaceTypeParametersSize : interfaceTypeParametersSize - 1\n                    );\n\n                    if (painlessMethod == null) {\n                        throw new IllegalArgumentException(\n                            Strings.format(\n                                \"function reference [%s::%s/%d] matching [%s, %s/%d] not found\",\n                                typeName,\n                                methodName,\n                                interfaceTypeParametersSize,\n                                targetClassName,\n                                interfaceMethodName,\n                                interfaceTypeParametersSize\n                            )\n                        );\n                    }\n                } else if (captured) {\n                    throw new IllegalArgumentException(\n                        Strings.format(\n                            \"cannot use a static method as a function reference [%s::%s/%d] with a non-static captured variable\",\n                            typeName,\n                            methodName,\n                            interfaceTypeParametersSize","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-painless/src/main/java/org/elasticsearch/painless/FunctionRef.java#L173-L209","documentation":"FunctionRef.create throws this IllegalArgumentException at compile time when a method reference 'Type::methodName' cannot resolve any whitelisted Painless method (static or instance) matching the name and arity. The compiler first tries an augmented instance method lookup, then a static method lookup with adjusted arity; if both return null, no accessible method of that class with that name and parameter count exists in the Painless allowlist.","triggerScenarios":"Writing 'String::fooBar' where fooBar does not exist or is not whitelisted. Writing 'List::size' when List is not allowed or size is not whitelisted. Mismatched arity: the functional interface expects N parameters but the referenced method has a different count.","commonSituations":"Typos in method names. Referencing methods on classes not whitelisted in Painless. Methods that exist in Java but are excluded from the Painless API surface for safety. Version differences where a method was removed or renamed.","solutions":["Verify the method name is spelled correctly and exists on the referenced class.","Confirm the class and method are whitelisted in the Painless API (check the allowed methods list for your ES version).","Adjust the functional interface arity to match the method's parameter count (remember instance methods consume one parameter for the receiver)."],"exampleFix":"// before\nFunction<String, String> f = String::reversed;  // typo, method is 'reverse' or doesn't exist\n// after\nFunction<StringBuilder, StringBuilder> f = StringBuilder::reverse;","handlingStrategy":"validation","validationCode":"// Verify the method exists and is whitelisted with matching arity:\n// // Check the Painless API docs for the class's allowed methods","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm method name spelling and whitelist status before referencing.","Account for the receiver parameter when matching instance method arity.","Use explicit lambdas as a fallback when references fail to resolve."],"tags":["painless","elasticsearch","method-reference","whitelist","compile-time"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}