Java 编译时交集有用吗?
Java 标准允许在编译时操作 AST。然而,API 没有标准,每个编译器的实现方式都不同(甚至在版本之间也是如此)。在工作中,我们曾经有过一些混合编译时间和加载时间交集的黑客行为。我们现在正在转变为以 Eclipse 为中心的开发流程,而这个 hack 给我们带来了一些麻烦。
我编写了一个 JVM 代理,它加载 Javassist 转换器并重写字节码,消除了编译时交集的需要,并解决了我们的问题。
我的问题是:Java 编译时的交集有用吗?是否存在无法在加载时使用交集来实现的用例?
The Java standard allows the manipulation of the AST at compile time. However there is no standard about the API and every compiler implements it differently (even between versions). At work we used to had some hack mixing compile time and load time intersection. We now are changing into a eclipse focused development process and this hack is giving us some trouble.
I wrote a JVM Agent that loads a Javassist transformer and rewrites the bytecode, removing the need of compile time intersection, and solving our problems.
My question is: Is Intersection at Compile Time for Java useful? Is there a use case in which you can't do it using intersection at load time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
致力于非公共 API 听起来并不明智。由于没有通过发布 API 进行公开承诺而发生变化时会发生什么?
添加编译后步骤并使用 ASM。
Doesnt sound to smart to commit to a non public API. What happens when it changes, because there is no public commitment by publishing an API ?
Add a post compile step and use ASM.