{"record":{"id":"b211648f85f113fd","repo":"JakeWharton/butterknife","slug":"must-have-at-most-parameter-s","errorCode":null,"errorMessage":" must have at most  parameter(s).","messagePattern":" must have at most  parameter\\(s\\)\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":1028,"sourceCode":"  }\n\n  private static boolean isRequired(Method method) {\n    return method.getAnnotation(Optional.class) == null;\n  }\n\n  private static ArgumentTransformer createArgumentTransformer(Method method,\n      Class<?>[] callbackParameterTypes) {\n    Class<?>[] targetParameterTypes = method.getParameterTypes();\n\n    int targetParameterLength = targetParameterTypes.length;\n    if (targetParameterLength == 0) {\n      // Special case the common case of no arguments.\n      return ArgumentTransformer.EMPTY;\n    }\n\n    int callbackParameterLength = callbackParameterTypes.length;\n    if (targetParameterLength > callbackParameterLength) {\n      throw new IllegalStateException(method.getDeclaringClass().getName()\n          + \".\"\n          + method.getName()\n          + \" must have at most \"\n          + callbackParameterLength\n          + \" parameter(s).\");\n    }\n\n    if (Arrays.equals(targetParameterTypes, callbackParameterTypes)) {\n      // Special case the common case of exact argument match.\n      return ArgumentTransformer.IDENTITY;\n    }\n\n    boolean[] callbackIndexUsed = new boolean[callbackParameterLength];\n    final int[] indexMap = new int[targetParameterLength];\n    nextTarget: for (int targetIndex = 0; targetIndex < targetParameterLength; targetIndex++) {\n      Class<?> targetParameterType = targetParameterTypes[targetIndex];\n      for (int callbackIndex = 0; callbackIndex < callbackParameterLength; callbackIndex++) {\n        if (callbackIndexUsed[callbackIndex]) {","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L1010-L1046","documentation":"Thrown by ButterKnife's reflection binder (createArgumentTransformer) when an @On* listener method declares more parameters than the framework callback it wraps provides. ButterKnife can forward at most as many arguments as the real listener passes (it matches them by type, in any order), so a longer parameter list cannot be satisfied.","triggerScenarios":"ButterKnife.bind(...) via butterknife-reflect where e.g. `@OnClick(R.id.button) void click(View v, int position)` (2 params > OnClickListener's 1 param) or an @OnCheckedChanged method taking (CompoundButton, boolean, int).","commonSituations":"Copying a method signature from an AdapterView listener (which has more params) onto a plain click handler, or adding extra context parameters (position, tag) that the developer assumed ButterKnife would inject. The compiler path reports this at build time; reflect throws during bind.","solutions":["Trim the method parameters to at most the callback's parameter count (e.g. 0 or 1 (View) for @OnClick).","Look up the listener interface ButterKnife wraps for that annotation and copy its exact signature, or use none.","Move to butterknife-compiler for a compile-time error."],"exampleFix":"// before\n@OnClick(R.id.buy) void buy(View v, int position) { }\n\n// after\n@OnClick(R.id.buy) void buy(View v) { }","handlingStrategy":"validation","validationCode":"// e.g. @OnClick supplies 1 callback parameter (View)\nif (method.getParameterTypes().length > 1) {\n  throw new IllegalStateException(method\n      + \" must have at most 1 parameter(s).\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Limit listener-method parameters to the wrapped callback's count (usually 0 or 1).","ButterKnife only forwards actual callback arguments — it never injects positions/ids.","Use butterknife-compiler for compile-time signature checking."],"tags":["butterknife","reflection","listener","parameters","annotation"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}