FasterXML/jackson-databind · error · UnsupportedOperationException

Cannot call createParameterObject() on ${getClass().getName(

Error message

Cannot call createParameterObject() on ${getClass().getName()}

What it means

createParameterObject() on the base SettableAnyProperty throws UnsupportedOperationException because only specific subclasses (e.g. the creator/parameter variant) know how to instantiate the any-setter's target object. The base implementation exists so that subclasses which never participate in property-based creators fail loudly rather than silently return null.

Source

Thrown at src/main/java/tools/jackson/databind/deser/SettableAnyProperty.java:177

     *
     * @since 2.18.1
     */
    public boolean isFieldType() { return _setterIsField; }

    /**
     * Method called to check whether this property is method
     *
     * @return 2.18.2
     */
    public boolean isSetterType() { return _setter instanceof AnnotatedMethod; }

    /**
     * Create an instance of value to pass through Creator parameter.
     *
     * @since 2.18
     */
    public Object createParameterObject() {
        throw new UnsupportedOperationException("Cannot call createParameterObject() on " + getClass().getName());
    }

    /*
    /**********************************************************************
    /* Public API, deserialization
    /**********************************************************************
     */

    /**
     * Method called to deserialize appropriate value, given parser (and
     * context), and set it using appropriate method (a setter method).
     */
    public void deserializeAndSet(JsonParser p, DeserializationContext ctxt,
            Object instance, String propName)
        throws JacksonException
    {
        try {
            Object key = (_keyDeserializer == null) ? propName

View on GitHub (pinned to 87876ca5c0)

Solutions

  1. Bind @JsonAnySetter to a Map field or setter method instead of a creator parameter if you do not need the parameter variant.
  2. If subclassing SettableAnyProperty for a creator parameter, override createParameterObject() to return the empty container (e.g. new LinkedHashMap<>()).
  3. Ensure your @JsonCreator and @JsonAnySetter are on compatible members (constructor parameter typed as Map).

Example fix

// before
public class Foo {
    @JsonAnySetter
    public void add(String k, Object v) { ... } // method any-setter
}
fooDeserializer.createParameterObject(); // throws

// after (creator/parameter variant)
public record Foo(@JsonAnySetter Map<String,Object> extra) {}
// the framework constructs ParameterAnyProperty which overrides createParameterObject()
Defensive patterns

Strategy: validation

Validate before calling

if (anyProp.getClass() == SettableAnyProperty.class) {
    throw new IllegalStateException(
        "Base SettableAnyProperty cannot back a creator parameter; bind @JsonAnySetter to a Map.");
}

Type guard

static boolean supportsParameterObject(SettableAnyProperty p) {
    return p.getClass() != SettableAnyProperty.class; // subclass must override
}

Try / catch

try { anyProp.createParameterObject(); }
catch (UnsupportedOperationException e) {
    // rebind @JsonAnySetter to a Map-typed constructor parameter
}

Prevention

When it happens

Trigger: A @JsonAnySetter bound to a constructor/factory parameter where the SettableAnyProperty variant does not override createParameterObject(); a custom BeanDeserializerFactory wiring the base SettableAnyProperty into a property-based creator; reflection-based tests or frameworks invoking createParameterObject() directly on the base type.

Common situations: Mixing @JsonAnySetter with @JsonCreator on records/builders in a way the introspector did not map to a parameter-capable any-setter; subclassing SettableAnyProperty without overriding the method; a custom module replacing the any-setter implementation.

Related errors


AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11). Data as JSON: /api/errors/3cf3b8696b2807c8. Report an issue: GitHub.