New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
android gradle 2.1.2环境下,解析匿名内部类的时候,会卡死 #778
Milestone
Comments
能提供一下类信息么,方便我重现 |
public class JsonParseTest extends AppCompatActivity{
public void runTest(){
long now = System.currentTimeMillis();
JSON.toJSON(new RequestData(){});
Log.i("PARSE TIME", " cost time: " + (System.currentTimeMillis() - now) + "ms");
}
}
abstract class RequestData{
} 然后运行runTest就会卡主, |
提交的代码,注释写错了issue,应该是#779,请忽略 |
问题已经修复,我会在今天发布一个版本 |
问题没有完全解决,悲剧了。。。 |
请使用最新版本1.1.55.android |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2.1.2 编译出来的内部类的
this$0
是public final
,所以使用getFields
会返回。这样会导致
JSON.toJSONBytes(obj)
的时候,去解析了this$0
我测试项目中的
this$0
是一个MainActivity
,里面有个getAction
的方法,但是没有相应action
,_action
, 'm_action'的成员变量。这样
ParseConfig
去计算getField
的时候会遍历所有的父类,MainActivty
有11层父类,每一层都会去找 fieldName,_fieldName, m_fieldName这三个属性值,所以找到最后一层Context
的时候会有100*3^12
的计算量,在这边就卡死了。我认为对于
getAction()
,计算所有的组合是没必要的,方便起见计算action
,_action
, 'm_action'就可以了,如果_m_action
,m__m_action
,_m_m_action
... 等所有的情况都计算的话,层数一多很耗时。The text was updated successfully, but these errors were encountered: