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

增强 java.lang.ClassLoader ,允许加载插件注册的类 #7

Open
hengyunabc opened this issue Oct 15, 2020 · 1 comment
Open

Comments

@hengyunabc
Copy link
Collaborator

在插件增强目标类的字节码之后,通常会插入 插件自身的代码,那么要解决这些插入的代码的加载问题。

常见的办法有几种:

  • 把插件的jar,强行加到ClassLoader的 urls里,像pinpoint就这样子的
  • 把插件的jar,加到 system classloader的 urls,或者 bootstrap classloader的 urls

还有一种办法是增强 java.lang.ClassLoader ,在 loadClass 函数里,查找到插件的类,直接返回。

同时可能还要修改 checkPackageAccess 函数。

@hengyunabc
Copy link
Collaborator Author

需要有一个非常高效的类匹配器,并且,只允许匹配全类名,或者某个package。

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

1 participant