如何使 Loadtime-AspectJ 在小程序中工作
由于 AspectJ LoadTime-Weaving 需要使用代理/它自己的类加载器加载 JVM - 有没有办法从我的小程序加载/更改用户的 JVM? 或者也许就在加载小程序之前(使用父小程序?)
Since AspectJ LoadTime-Weaving needs to load the JVM with an agent/it's own classloader - is there a way to load/make changes in the user's JVM from my applet? or maybe just before loading the applet (with a parent applet?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
恐怕你在那里会完全不走运。 根据 Sun 关于 applet 类加载器的文档,“Web 浏览器仅使用一个类加载器,此后,系统类加载器无法扩展、重载、覆盖或替换。Applet 无法创建或引用自己的类加载器”(强调我的)。
通过编译时编织解决这个问题可能会取得更大的成功,除非有某种原因你不能这样做。
但是,如果小程序已签名,您也许可以解决此问题。 AspectJ 不太清楚它对 Java 安全性的要求是什么。 我会进入 AspectJ 邮件列表并询问。
I'm afraid you'll be completely out of luck there. According to the Sun docs on applet classloaders, a "web browser uses only one class loader, which is established at start-up. Thereafter, the system class loader cannot be extended, overloaded, overridden or replaced. Applets cannot create or reference their own class loader" (emphasis mine).
You will probably have more success with compile-time weaving on this problem, unless there's some reason why you can't do that.
If the applet is signed, however, you might be able to work around this. AspectJ is not really clear on what its requirements are by way of Java Security. I'd get on the AspectJ mailing list and ask.
可能可以在 JVM 启动后添加编织代理,请参阅:
如何添加 Javaagent到 JVM 而不停止 JVM?
It might be possible to add a weaving agent after the JVM is started, see:
How can I add a Javaagent to a JVM without stopping the JVM?