{"record":{"id":"ef3da7a99feb2f2e","repo":"JakeWharton/butterknife","slug":"bindviews-list-must-have-a-generic-component","errorCode":null,"errorMessage":"@BindViews List must have a generic component. (","messagePattern":"@BindViews List must have a generic component\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":284,"sourceCode":"    BindViews bindViews = field.getAnnotation(BindViews.class);\n    if (bindViews == null) {\n      return null;\n    }\n    validateMember(field);\n\n    Class<?> fieldClass = field.getType();\n    Class<?> viewClass;\n    boolean isArray = fieldClass.isArray();\n    if (isArray) {\n      viewClass = fieldClass.getComponentType();\n    } else if (fieldClass == List.class) {\n      Type fieldType = field.getGenericType();\n      if (fieldType instanceof ParameterizedType) {\n        Type viewType = ((ParameterizedType) fieldType).getActualTypeArguments()[0];\n        // TODO real rawType impl!!!!\n        viewClass = (Class<?>) viewType;\n      } else {\n        throw new IllegalStateException(\"@BindViews List must have a generic component. (\"\n            + field.getDeclaringClass().getName()\n            + '.'\n            + field.getName()\n            + ')');\n      }\n    } else {\n      throw new IllegalStateException(\"@BindViews must be a List or array. (\"\n          + field.getDeclaringClass().getName()\n          + '.'\n          + field.getName()\n          + ')');\n    }\n    if (!View.class.isAssignableFrom(viewClass) && !viewClass.isInterface()) {\n      throw new IllegalStateException(\n          \"@BindViews List or array type must extend from View or be an interface. (\"\n              + field.getDeclaringClass().getName()\n              + '.'\n              + field.getName()","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L266-L302","documentation":"parseBindViews accepts a List field only if its generic type is a parameterized type, so it can extract the component (element) view class from the type argument. A raw `List` (or a List whose generic info is erased/unavailable at reflection time) leaves no component class, so bind throws this IllegalStateException.","triggerScenarios":"Declaring `@BindViews({R.id.a, R.id.b}) List views;` without a type argument; using a raw List type from a pre-generics codebase or an unchecked cast that erases the parameterization.","commonSituations":"Old Java 1.4-style code reused with ButterKnife; IDE warnings about raw types ignored; fields typed as List after refactoring away the generic parameter.","solutions":["Parameterize the field: `@BindViews({...}) List<TextView> textViews;`","If you cannot use generics, switch to a typed array: `@BindViews({...}) TextView[] textViews;`"],"exampleFix":"// before\n@BindViews({R.id.first, R.id.second})\nList labels; // raw List\n\n// after\n@BindViews({R.id.first, R.id.second})\nList<TextView> labels;","handlingStrategy":"type-guard","validationCode":"if (field.getType() == List.class\n    && !(field.getGenericType() instanceof ParameterizedType)) {\n  throw new IllegalStateException(\"Raw List for @BindViews: \" + field);\n}","typeGuard":"static boolean isParameterizedList(Field f) {\n  return f.getType() == List.class\n      && f.getGenericType() instanceof ParameterizedType;\n}","tryCatchPattern":null,"preventionTips":["Always declare @BindViews fields as List<SomeView> or SomeView[]","Treat raw-type compiler warnings as errors in ButterKnife-using modules"],"tags":["butterknife","runtime","reflection","generics"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}