{"record":{"id":"7465f716b2620776","repo":"FasterXML/jackson-databind","slug":"annotationintrospector-returned-class-expected-7465f7","errorCode":null,"errorMessage":"AnnotationIntrospector returned Class {}; expected Class<ValueInstantiator>","messagePattern":"AnnotationIntrospector returned Class (.+?); expected Class<ValueInstantiator>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java","lineNumber":294,"sourceCode":"            return null;\n        }\n\n        ValueInstantiator inst;\n\n        if (instDef instanceof ValueInstantiator valueInstantiator) {\n            return valueInstantiator;\n        }\n        if (!(instDef instanceof Class)) {\n            throw new IllegalStateException(\"AnnotationIntrospector returned key deserializer definition of type \"\n                    +instDef.getClass().getName()\n                    +\"; expected type KeyDeserializer or Class<KeyDeserializer> instead\");\n        }\n        Class<?> instClass = (Class<?>)instDef;\n        if (ClassUtil.isBogusClass(instClass)) {\n            return null;\n        }\n        if (!ValueInstantiator.class.isAssignableFrom(instClass)) {\n            throw new IllegalStateException(\"AnnotationIntrospector returned Class \"+instClass.getName()\n                    +\"; expected Class<ValueInstantiator>\");\n        }\n        HandlerInstantiator hi = config.getHandlerInstantiator();\n        if (hi != null) {\n            inst = hi.valueInstantiatorInstance(config, annotated, instClass);\n            if (inst != null) {\n                return inst;\n            }\n        }\n        return (ValueInstantiator) ClassUtil.createInstance(instClass,\n                config.canOverrideAccessModifiers());\n    }\n\n    /*\n    /**********************************************************************\n    /* Creator introspection: new (2.18) helper methods\n    /**********************************************************************\n     */","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java#L276-L312","documentation":"Thrown from BasicDeserializerFactory._valueInstantiatorInstance when the introspector returns a Class for the value instantiator, but that Class does not extend ValueInstantiator. Only ValueInstantiator subclasses can be instantiated to drive object creation.","triggerScenarios":"@JsonValueInstantiator(MyClass.class) where MyClass does not extend ValueInstantiator, or a custom introspector returning a non-instantiator Class for value-instantiator resolution.","commonSituations":"Pointing @JsonValueInstantiator at a factory, builder, or plain class by mistake; a refactor that changed a class hierarchy without updating the annotation; confusing ValueInstantiator with ValueDeserializer.","solutions":["Make the referenced class extend ValueInstantiator (or ValueInstantiator.Base) and implement createUsingDefault / createFromObjectWith.","If you did not intend to customize instantiation, remove the @JsonValueInstantiator annotation.","Verify the class hierarchy before wiring."],"exampleFix":"// before\n@JsonValueInstantiator(MyFactory.class) // MyFactory does not extend ValueInstantiator\nclass MyFactory { Object create(){ ... } }\n// after\nclass MyInstantiator extends ValueInstantiator.Base<MyBean> {\n    @Override public MyBean createUsingDefault(DeserializationContext ctxt){ return new MyBean(); }\n}\n@JsonValueInstantiator(MyInstantiator.class)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isInstantiatorClass(Class<?> c) {\n    return c != null && ValueInstantiator.class.isAssignableFrom(c);\n}","tryCatchPattern":null,"preventionTips":["Verify the @JsonValueInstantiator target extends ValueInstantiator before deploying.","Base custom instantiators on ValueInstantiator.Base to get sensible defaults.","Don't confuse ValueInstantiator with ValueDeserializer."],"tags":["annotation-introspector","value-instantiator","type-mismatch"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}