{"record":{"id":"423037d6325d61b5","repo":"FasterXML/jackson-databind","slug":"type-not-java-enum-type","errorCode":null,"errorMessage":"Type {} not Java Enum type","messagePattern":"Type (.+?) not Java Enum type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/jdk/EnumSetDeserializer.java","lineNumber":66,"sourceCode":"     * to indicate whether single value may be taken to mean an unwrapped one-element array\n     * or not. If null, left to global defaults.\n     */\n    protected final Boolean _unwrapSingle;\n\n    /*\n    /**********************************************************************\n    /* Life-cycle\n    /**********************************************************************\n     */\n\n    @SuppressWarnings(\"unchecked\")\n    public EnumSetDeserializer(JavaType enumType, ValueDeserializer<?> deser)\n    {\n        super(EnumSet.class);\n        _enumType = enumType;\n        // sanity check\n        if (!enumType.isEnumType()) {\n            throw new IllegalArgumentException(\"Type \"+enumType+\" not Java Enum type\");\n        }\n        _enumDeserializer = (ValueDeserializer<Enum<?>>) deser;\n        _unwrapSingle = null;\n        _nullProvider = null;\n        _skipNullValues = false;\n    }\n\n    @SuppressWarnings(\"unchecked\" )\n    protected EnumSetDeserializer(EnumSetDeserializer base,\n            ValueDeserializer<?> deser,\n            NullValueProvider nuller, Boolean unwrapSingle) {\n        super(base);\n        _enumType = base._enumType;\n        _enumDeserializer = (ValueDeserializer<Enum<?>>) deser;\n        _nullProvider = nuller;\n        _skipNullValues = NullsConstantProvider.isSkipper(nuller);\n        _unwrapSingle = unwrapSingle;\n    }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/jdk/EnumSetDeserializer.java#L48-L84","documentation":"Thrown by the EnumSetDeserializer constructor (sanity check) when the JavaType passed for the enum set's element type is not actually a Java enum type. The constructor calls enumType.isEnumType() and rejects non-enum types. This is a configuration/type-resolution error indicating that an EnumSet deserializer was constructed for a non-enum element type.","triggerScenarios":"Constructing an EnumSetDeserializer directly with a JavaType whose raw class is not an enum. A custom module or deserializer factory that routes a non-enum type to EnumSetDeserializer. A type resolution bug where the element type of an EnumSet resolves to a raw or erased type.","commonSituations":"Custom module code that manually creates EnumSetDeserializer instances. Erasure issues with generic EnumSet fields where the element type is not properly resolved. Type erasure on a field declared as EnumSet (raw) without a type parameter.","solutions":["Ensure the JavaType passed to EnumSetDeserializer has a concrete enum raw class (e.g., MyEnum.class, not Object.class or Enum.class).","If declaring EnumSet fields, always parameterize them: EnumSet<MyEnum> not raw EnumSet.","In custom factories, check enumType.isEnumType() before constructing the deserializer.","Use TypeFactory to construct the correct parameterized type if resolving from reflection metadata."],"exampleFix":"// before: raw EnumSet, type erasure yields non-enum element type\nprivate EnumSet myEnumSet;\n// after: properly parameterized\nprivate EnumSet<MyEnum> myEnumSet;","handlingStrategy":"type-guard","validationCode":"// Ensure the JavaType is an enum before constructing EnumSetDeserializer\nif (enumType.isEnumType()) {\n    new EnumSetDeserializer(enumType, deser);\n} else {\n    throw new IllegalArgumentException(\"Not an enum: \" + enumType);\n}","typeGuard":"static boolean isEnumElementType(JavaType type) {\n    return type.isEnumType() && type.getRawClass().isEnum();\n}","tryCatchPattern":null,"preventionTips":["Always parameterize EnumSet fields: EnumSet<MyEnum>, never raw EnumSet.","In custom factories, validate isEnumType() before constructing EnumSetDeserializer.","Use TypeFactory to correctly resolve enum element types from reflection."],"tags":["jackson","deserialization","enum","enumset","type-resolution"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}