{"record":{"id":"f6054df09cdc08c6","repo":"FasterXML/jackson-databind","slug":"only-support-javatype-implementation-of-resolve","errorCode":null,"errorMessage":"Only support `JavaType` implementation of `ResolvedType`, not: {}","messagePattern":"Only support `JavaType` implementation of `ResolvedType`, not: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/DeserializationContext.java","lineNumber":393,"sourceCode":"     * rather use {@link #readPropertyValue(JsonParser, BeanProperty, Class)};\n     * this method does not allow use of contextual annotations.\n     */\n    @Override\n    public <T> T readValue(JsonParser p, Class<T> type) throws JacksonException {\n        return readValue(p, getTypeFactory().constructType(type));\n    }\n\n    @Override\n    public <T> T readValue(JsonParser p, TypeReference<T> refType) throws JacksonException {\n        return readValue(p, getTypeFactory().constructType(refType));\n    }\n\n    @Override\n    public <T> T readValue(JsonParser p, ResolvedType type) throws JacksonException {\n        if (type instanceof JavaType jt) {\n            return readValue(p, jt);\n        }\n        throw new UnsupportedOperationException(\n                \"Only support `JavaType` implementation of `ResolvedType`, not: \"+type.getClass().getName());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public <T> T readValue(JsonParser p, JavaType type) throws JacksonException {\n        ValueDeserializer<Object> deser = findRootValueDeserializer(type);\n        if (deser == null) {\n            reportBadDefinition(type,\n                    \"Could not find `ValueDeserializer` for type \"+ClassUtil.getTypeDescription(type));\n        }\n        return (T) _readValue(p, deser);\n    }\n\n    /**\n     * Helper method that should handle special cases for deserialization; most\n     * notably handling {@code null} (and possibly absent values).\n     */\n    private Object _readValue(JsonParser p, ValueDeserializer<Object> deser) throws JacksonException","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/DeserializationContext.java#L375-L411","documentation":"DeserializationContext.readValue(JsonParser, ResolvedType) only knows how to handle a ResolvedType that is actually a JavaType (jackson-databind's own type representation). If a caller passes any other ResolvedType implementation, Jackson throws UnsupportedOperationException naming the offending class. In normal Jackson usage this is effectively unreachable because all internal code uses JavaType; it surfaces only when application code constructs a custom ResolvedType and hands it in.","triggerScenarios":"Calling ctxt.readValue(parser, someResolvedType) where someResolvedType is a third-party ResolvedType (e.g. from another Jackson family member or a hand-rolled impl) rather than a JavaType obtained from TypeFactory. Also seen when generic helper code is parameterized on ResolvedType and forwards a value of an unexpected concrete subtype.","commonSituations":"Writing framework code that abstracts over ResolvedType across multiple Jackson dataformats/cores; passing a value obtained from a non-databind API (e.g. a streaming-layer type token) directly into a databind readValue; version skew where a ResolvedType subclass existed in an older setup but not the JavaType expected here.","solutions":["Convert the ResolvedType to a JavaType first: use mapper.constructType(resolvedType) or typeFactory.constructType(...) before calling readValue.","If you only have a java.lang.reflect.Type or a TypeReference, construct a JavaType from that instead.","Avoid parameterizing your own helpers on ResolvedType; use JavaType throughout for databind operations.","If a custom ResolvedType subclass is truly needed, subclass JavaType instead so it passes the instanceof check."],"exampleFix":"// before\nResolvedType rt = ...; // some non-JavaType ResolvedType\nObject v = ctxt.readValue(p, rt);\n// after\nJavaType jt = mapper.getTypeFactory().constructType(rt);\nObject v = ctxt.readValue(p, jt);","handlingStrategy":"type-guard","validationCode":"// Always convert ResolvedType to JavaType before readValue\nJavaType jt = (type instanceof JavaType)\n    ? (JavaType) type\n    : mapper.getTypeFactory().constructType(type);\nctxt.readValue(parser, jt);","typeGuard":"boolean isJavaType(ResolvedType t) { return t instanceof JavaType; }","tryCatchPattern":null,"preventionTips":["Parameterize your helpers on JavaType, not ResolvedType, for any databind read path.","Construct types via TypeFactory.constructType(...) so you always hold a JavaType.","Avoid subclassing ResolvedType directly; subclass JavaType if you need custom type metadata."],"tags":["deserialization","type-system","api-misuse"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}