{"record":{"id":"b0385780ad33a9bf","repo":"alibaba/ARouter","slug":"unsupported-primitive-type-type","errorCode":null,"errorMessage":"Unsupported primitive type: <type>","messagePattern":"Unsupported primitive type: <type>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/AutowiredProcessor.java","lineNumber":252,"sourceCode":"        switch (TypeKind.values()[type]) {\n            case BOOLEAN:\n                return \"getBoolean\";\n            case BYTE:\n                return \"getByte\";\n            case SHORT:\n                return \"getShort\";\n            case INT:\n                return \"getInt\";\n            case LONG:\n                return \"getLong\";\n            case CHAR:\n                return \"getChar\";\n            case FLOAT:\n                return \"getFloat\";\n            case DOUBLE:\n                return \"getDouble\";\n            default:\n                throw new IllegalArgumentException(\"Unsupported primitive type: \" + TypeKind.values()[type]);\n        }\n    }\n\n    /**\n     * Categories field, find his papa.\n     *\n     * @param elements Field need autowired\n     */\n    private void categories(Set<? extends Element> elements) throws IllegalAccessException {\n        if (CollectionUtils.isNotEmpty(elements)) {\n            for (Element element : elements) {\n                TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();\n\n                if (element.getModifiers().contains(Modifier.PRIVATE)) {\n                    throw new IllegalAccessException(\"The inject fields CAN NOT BE 'private'!!! please check field [\"\n                            + element.getSimpleName() + \"] in class [\" + enclosingElement.getQualifiedName() + \"]\");\n                }\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/alibaba/ARouter/blob/84f451d244e3fb1d0e37801de1b9ee2af2f81d68/arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/AutowiredProcessor.java#L234-L270","documentation":"Thrown by AutowiredProcessor.getBundleGetter when generating code that reads a field from a Bundle via a getter method. The switch over TypeKind primitive types (BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, CHAR, BOOLEAN) has no case for the given kind and falls into the default branch. It indicates an annotated @Autowired field whose type is a primitive (or boxed) kind that the compiler plugin does not know how to read from a Bundle.","triggerScenarios":"Annotating an @Autowired field with a type whose TypeKind is not one of the handled primitives (e.g. void, a boxed wrapper resolved to an unexpected kind, or an unusual primitive) so getBundleGetter's switch hits default during annotation processing.","commonSituations":"Autogenerate injection code for a field type the processor does not explicitly support; upgrading ARouter versions where a new exotic field type is added; generated helper covers Activity with Bundle-based injection.","solutions":["Change the @Autowired field to a supported type (int, long, boolean, String, Parcelable, Serializable, etc.).","If a special type is required, remove @Autowired and pass it manually via Intent extras and read it yourself.","Check the field's declared TypeKind and confirm it is one of BYTE/SHORT/INT/LONG/FLOAT/DOUBLE/CHAR/BOOLEAN handled in getBundleGetter."],"exampleFix":"// before\n@Autowired\nvolatile char flag;\n\n// after\n@Autowired\nString flag; // or use a supported primitive like boolean/int","handlingStrategy":"validation","validationCode":"// before compiling, audit annotated fields\nSet<Class<?>> SUPPORTED = Set.of(int.class, long.class, short.class, byte.class,\n    char.class, float.class, double.class, boolean.class, String.class);\nif (field.isAnnotationPresent(Autowired.class) && !SUPPORTED.contains(field.getType())) {\n    throw new IllegalStateException(\"Unsupported @Autowired field type: \" + field.getType());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only annotate fields of types listed in ARouter's supported injection types.","Pass complex objects as Serializable or Parcelable.","Review the field types table when upgrading ARouter versions."],"tags":["annotation-processor","arouter","compile-time"],"backgroundTag":"unsupported-enum-value","analyzedSha":"84f451d244e3fb1d0e37801de1b9ee2af2f81d68","analyzedAt":"2026-09-06T13:30:41.084Z","contentChangedAt":"2026-09-06T13:30:41.084Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}