-
Notifications
You must be signed in to change notification settings - Fork 511
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
ObjectReaderImplMap.of方法生成ReadObject时,希望mapType可以支持非public修饰的类 #557
Labels
Milestone
Comments
能够提供重现问题的TestCase么? |
|
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.10-SNAPSHOT/ |
感谢支持,已经验证无问题,期待新版本的发布 |
wenshao
added a commit
that referenced
this issue
Jul 14, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请描述您的需求或者改进建议
ObjectReaderImplMap.of方法生成ReadObject时,希望mapType可以支持非public修饰的类
例如:
private static class MyMap implements Map{ //..... }
ObjectReaderImplMap.of(new TypeReference<Map<String, Object>>() {}.getType(), MyMap.class, 0);
现在这么用会在运行到实例化Map时报错,问题出在ObjectReaderImplMapTyped.createInstance方法中
请描述你建议的实现方案
建议将ObjectReaderImplMapTyped.createInstance方法中instanceType.newInstance();实现修改为
try { Constructor<?> constructor = instanceType.getConstructor(); constructor.setAccessible(true); constructor.newInstance(); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JSONException("create map error"); }
The text was updated successfully, but these errors were encountered: