签名 jar 的 AspectJ 加载时编织
有人成功使用带有签名 jar 的 AspectJ 加载时编织吗?
我遇到了一个异常,不知道如何修复它(使用 AspectJ 1.6.8-16.10 进行测试):
Exception in thread "main" java.lang.NoClassDefFoundError: com/package/clazz$AjcClosure1
at com.package.test.main(test.java:55)
Caused by: java.lang.ClassNotFoundException: com.package.clazz$AjcClosure1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
坦率地说,我不确定它在技术上是否可行,但我知道类似的问题(使用从签名的 java 类动态生成的 java 代码) )是为 Hibernate 项目完成的(即使用 Javassist 而不是 CGLIB)。详细信息位于此处。
Does anybody success in using AspectJ load-time weaving with signed jars?
I got an exception and have no idea how to fix it (tested with AspectJ 1.6.8-16.10):
Exception in thread "main" java.lang.NoClassDefFoundError: com/package/clazz$AjcClosure1
at com.package.test.main(test.java:55)
Caused by: java.lang.ClassNotFoundException: com.package.clazz$AjcClosure1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
Frankly speaking I event not sure if it's technically possible, but I know that similar issue (using dynamically generated java code from signed java classes) was done for Hibernate project (i.e. using Javassist instead of CGLIB). Details are here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://bugs.eclipse.org/bugs/show_bug 中描述了类似的问题.cgi?id=328099 并在 AspectJ 1.6.12 中修复。 AspectJ 有时会在编织期间生成闭包类,并且必须使用与产生它们的 jar 相同的保护域来定义这些闭包类。在 1.6.12.M1 中,现在应该可以正常工作了。
The simular problem is described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=328099 and fixed in AspectJ 1.6.12. AspectJ sometimes generates closure classes during weaving and these must be defined with the same protection domain as the jar that gave rise to them. In 1.6.12.M1 this should now work correctly.