Skip to content
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

插件通过服务器下发至设备之后,如何反射调用插件中包含的类 #43

Open
jinbolx opened this issue Feb 20, 2021 · 4 comments

Comments

@jinbolx
Copy link

jinbolx commented Feb 20, 2021

通过as直接运行的形式是可以直接通过反射获取到插件中的类的,然后通过服务器下发至设备之后就不支持了,请问有方法解决吗

@JackyAnn
Copy link

@jinbolx
获取宿主ClassLoader, 通过ClassLoader#loadClass调用

@vincentlao
Copy link

@jinbolx
获取宿主ClassLoader, 通过ClassLoader#loadClass调用

是要获取插件的ClassLoader吧,这个ClassLoader如何获取?

@1282445717
Copy link

最后解决了吗

@JackyAnn
Copy link

@jinbolx @1282445717

要获取宿主的ClassLoader, 框架Hook替换了应用的ClassLoader, 用宿主的ClassLoader才会被框架拦截,然后去对应的插件找需要反射的类

Class.forName是无法反射插件中的类的,系统有检查,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants