FasterXML/jackson-databind · error · IllegalArgumentException
Type ${enumType} not Java Enum type
Error message
Type ${enumType} not Java Enum type What it means
EnumSetDeserializer's constructor enforces that the JavaType passed in is a real Java enum type (enumType.isEnumType()). If a non-enum type is supplied the deserializer cannot be built, because EnumSet requires an Enum element type at the JVM level. This is an internal invariant guard thrown as IllegalArgumentException during deserializer construction.
Source
Thrown at src/main/java/tools/jackson/databind/deser/jdk/EnumSetDeserializer.java:66
* to indicate whether single value may be taken to mean an unwrapped one-element array
* or not. If null, left to global defaults.
*/
protected final Boolean _unwrapSingle;
/*
/**********************************************************************
/* Life-cycle
/**********************************************************************
*/
@SuppressWarnings("unchecked")
public EnumSetDeserializer(JavaType enumType, ValueDeserializer<?> deser)
{
super(EnumSet.class);
_enumType = enumType;
// sanity check
if (!enumType.isEnumType()) {
throw new IllegalArgumentException("Type "+enumType+" not Java Enum type");
}
_enumDeserializer = (ValueDeserializer<Enum<?>>) deser;
_unwrapSingle = null;
_nullProvider = null;
_skipNullValues = false;
}
@SuppressWarnings("unchecked" )
protected EnumSetDeserializer(EnumSetDeserializer base,
ValueDeserializer<?> deser,
NullValueProvider nuller, Boolean unwrapSingle) {
super(base);
_enumType = base._enumType;
_enumDeserializer = (ValueDeserializer<Enum<?>>) deser;
_nullProvider = nuller;
_skipNullValues = NullsConstantProvider.isSkipper(nuller);
_unwrapSingle = unwrapSingle;
}View on GitHub (pinned to 87876ca5c0)
Solutions
- Verify the element type of the EnumSet is declared as a concrete enum, e.g. EnumSet<MyEnum>, and not EnumSet<?> or EnumSet<Object>.
- If you build the deserializer by hand, resolve the enum class via TypeFactory and pass JavaType.isEnumType()==true.
- Switch the field type from EnumSet to Set<YourType> when the element type is not guaranteed to be an enum.
- Audit custom Deserializers / SimpleModule registrations that might replace EnumSet handling with a wrong type.
Example fix
// before
public class Holder { public EnumSet<?> items; } // raw element type
// after
public enum Color { RED, GREEN }
public class Holder { public EnumSet<Color> items; } Defensive patterns
Strategy: validation
Validate before calling
JavaType t = mapper.constructType(elementClass);
if (!t.isEnumType()) {
throw new IllegalStateException("Refusing to build EnumSet deserializer for non-enum " + t);
} Type guard
boolean isEnumSetElementType(Class<?> cls) {
return cls != null && cls.isEnum();
} Prevention
- Always declare EnumSet fields with a concrete enum generic (EnumSet<MyEnum>, never EnumSet<?>).
- When registering custom deserializers, branch on type.isEnumType() before touching EnumSetDeserializer.
- Unit-test deserialization of every EnumSet field after enum refactors.
When it happens
Trigger: Constructing EnumSetDeserializer manually with a JavaType that is not an enum; using @JsonDeserialize on an EnumSet field whose generic argument resolves to a non-enum class; a TypeFactory/TypeBinding misconfiguration that erases or replaces the enum element type before the deserializer is built.
Common situations: Refactoring an enum into a regular class and forgetting to update an EnumSet-typed field; mixed type bindings with custom modules that swap the element type; generic type erasure in a wrapper that passes raw or wildcard types into an EnumSet context.
Related errors
- Missing generic type information for "+type
- Cannot construct EnumMap; generic (key) type not available
- Unsuitable method ({}) decorated with @JsonCreator (for Enum
- Trying to resolve a forward reference with id [${id}] that w
- Argument `allowedSchemes` must not be null
AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11).
Data as JSON: /api/errors/d7ace2d683e04328.
Report an issue: GitHub.