Conversation
…Object In the fastjson1-compatible module, JSON.toJavaObject(json, clazz) delegates to ObjectReader.createInstance. On some JDK/architecture combinations (e.g. ARM aarch64 JDK8) this throws IntrospectionException when the source JSONObject contains an extra field whose key is not a property of the target bean (e.g. "/*"), while x86-64 JDK8 silently ignores it. fastjson 1.2.83 caught this exception internally; the 2.0.x compat layer omitted that logic during porting. Catch the exception and fall back to a property-by-property copy that only sets the target bean's own properties and drops unknown keys, restoring consistent cross-platform behavior. Fixes alibaba#7782
wylovelyi
force-pushed
the
fix/issue-7782
branch
from
September 14, 2026 05:52
b48d6f7 to
d240d46
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the
fastjson1-compatiblemodule,JSON.toJavaObject(json, clazz)delegates toObjectReader.createInstance. When the sourceJSONObjectcontains an extra field whose key is not a property of the target bean (e.g./*),createInstancethrowsIntrospectionExceptionon some JDK/architecture combinations (reported on ARM aarch64 JDK8), while x86-64 JDK8 silently ignores it. fastjson 1.2.83 caught this exception internally; the 2.0.x compat layer dropped that logic during the port, causing inconsistent cross-platform behavior (see #7782).Root cause
JSONObject.toJavaObject(Class)callsobjectReader.createInstance(this, ...)without the defensiveIntrospectionExceptionhandling that fastjson 1.2.83 had.Fix
Wrap the
createInstancecall in a try/catch. On failure, fall back to a property-by-property copy that only sets the target bean's own writable properties viajava.beans.Introspector, dropping unknown keys — restoring the 1.x behavior consistently on all platforms.Test
Added
Issue7782regression test: aJSONObjectwith a normalnamefield plus an extra/*field is converted to the target bean; the bean is produced andnameis correctly populated.Fixes #7782