{"record":{"id":"dd83cde3737f8bf8","repo":"clojure/clojure","slug":"error-no-matches-found-for-kind-methodkind","errorCode":null,"errorMessage":"Error - no matches found for ${kind != MethodKind.CTOR ? kind.toString().toLowerCase() + \" \" : \"\"}${methodDescription(c, methodName)}","messagePattern":"Error - no matches found for (.+?)(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/jvm/clojure/lang/Compiler.java","lineNumber":1307,"sourceCode":"\t\treturn Arrays.stream(methods)\n\t\t\t\t.filter(m -> m.getName().equals(methodName))\n\t\t\t\t.filter(m -> {\n\t\t\t\t\tswitch(kind) {\n\t\t\t\t\t\tcase STATIC: return isStaticMethod(m);\n\t\t\t\t\t\tcase INSTANCE: return isInstanceMethod(m);\n\t\t\t\t\t\tdefault: return false;\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.collect(Collectors.toList());\n\t}\n\n\t// Returns a list of methods or ctors matching the name and kind given.\n\t// Otherwise, will throw if the information provided results in no matches\n\tprivate static List<Executable> methodsWithName(Class c, String methodName, MethodKind kind) {\n\t\tif (kind == MethodKind.CTOR) {\n\t\t\tList<Executable> ctors = Arrays.asList(c.getConstructors());\n\t\t\tif(ctors.isEmpty())\n\t\t\t\tthrow noMethodWithNameException(c, methodName, kind);\n\t\t\treturn ctors;\n\t\t}\n\n\t\tList<Executable> res = methodOverloads(c, methodName, kind);\n\n\t\tif(res.isEmpty())\n\t\t\tthrow noMethodWithNameException(c, methodName, kind);\n\t\treturn res;\n\t}\n\n\tstatic Executable resolveHintedMethod(Class c, String methodName, MethodKind kind, List<Class> hintedSig) {\n\t\tList<Executable> methods = methodsWithName(c, methodName, kind);\n\t\tfinal int arity = hintedSig.size();\n\t\tList<Executable> filteredMethods = methods.stream()\n\t\t\t\t.filter(m -> m.getParameterCount() == arity)\n\t\t\t\t.filter(m -> !m.isSynthetic()) // remove bridge/lambda methods\n\t\t\t\t.filter(m -> signatureMatches(hintedSig, m))\n\t\t\t\t.collect(Collectors.toList());","sourceCodeStart":1289,"sourceCodeEnd":1325,"githubUrl":"https://github.com/clojure/clojure/blob/f3b143341d6efc6428b523b2eaa099a6cc99156e/src/jvm/clojure/lang/Compiler.java#L1289-L1325","documentation":"The Java compiler's reflection-based method resolution collects candidate methods or constructors matching a name and MethodKind. When the candidate list is empty — no constructor exists, or no method overloads with that name/kind match — it throws this descriptive RuntimeException via noMethodWithNameException.","triggerScenarios":"Compiling Clojure code that calls a Java constructor that does not exist for the class, or invokes a method name that has no overloads of the expected kind (instance vs static), so methodsWithName finds zero matches.","commonSituations":"Typos in method names in interop forms; calling static methods with instance-call syntax or vice versa; constructor arity that doesn't exist; upgrading a Java dependency where methods/constructors were removed or renamed; reflection failing to find members on the resolved class.","solutions":["Check the class for the exact method/constructor name and arity via (clojure.reflect/reflect ClassName) or javap","Fix static/instance call syntax: (ClassName/method args) for static, (. obj method args) for instance","If a dependency upgrade removed the member, pin the old version or migrate to the replacement API","Add type hints so reflection resolves to the intended class with the expected members","Verify the argument types/arities match an existing overload"],"exampleFix":"// before: String has no zero-arg static valueOf(String)\n(String/valueOf) ; or wrong kind/arity => no matches\n// after\n(String/valueOf \"x\") ; matches existing overload","handlingStrategy":"validation","validationCode":"(defn member-exists? [c name]\n  (some #(= name (str (:name %)))\n        (concat (:members (clojure.reflect/reflect c))\n                (:members (clojure.reflect/reflect c :authorize [#.toString])))))","typeGuard":null,"tryCatchPattern":"try {\n  List<Executable> ms = methodsWithName(c, name, kind);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Error - no matches found\")) {\n    throw new IllegalStateException(\"Check method name/kind/arity for \" + c.getName(), e);\n  }\n  throw e;\n}","preventionTips":["Verify member existence with clojure.reflect or javap before interop calls","Match static vs instance call syntax to the member's actual kind","Check dependency changelogs for removed/renamed Java methods on upgrades","Use type hints to ensure reflection resolves the intended class"],"tags":["reflection","interop","method-resolution","compiler","clojure"],"backgroundTag":"method-not-found","analyzedSha":"f3b143341d6efc6428b523b2eaa099a6cc99156e","analyzedAt":"2026-09-09T12:04:58.961Z","contentChangedAt":"2026-09-09T12:04:58.961Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}