fix: Lambda creation failed, fallback to parent's reflection implemen…#4012
Open
xihan123 wants to merge 3 commits intoalibaba:mainfrom
Open
fix: Lambda creation failed, fallback to parent's reflection implemen…#4012xihan123 wants to merge 3 commits intoalibaba:mainfrom
xihan123 wants to merge 3 commits intoalibaba:mainfrom
Conversation
Member
|
单测跑不过,merge from main分支试下 |
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.
What this PR does / why we need it?
修复 Android 环境下使用 JSON.parseObject、JSON.toJSONString 等方法时抛出的 NullPointerException。
在 Android 平台上,MethodHandles.Lookup.in() 方法可能返回 null,导致 Lambda 创建失败并抛出异常。此 PR 使 PropertyAccessorFactoryLambda 在 Lambda
创建失败时能够回退到父类的反射实现,而不是直接抛出异常导致程序崩溃。
Fixes #4011
Summary of your change
修改 PropertyAccessorFactoryLambda.create() 方法,在 Lambda 创建逻辑外层添加 try-catch 块。当 Lambda 创建失败(抛出 Throwable)时,捕获异常并忽略,然后继续执行到最后的
return super.create(...) 语句,回退到父类的反射实现。
Please indicate you've done the following: