是否有像Javassist这样的Scala感知高级字节码操作工具? [英] Is there Scala aware high level byte-code manipulation tool like Javassist?

查看:105
本文介绍了是否有像Javassist这样的Scala感知高级字节码操作工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找像Javassist这样的高级字节码操作工具,但这可以理解Scala的某些特性。较低级别的字节码操作工具应该相对不可知,但是就我的用例而言,Javassist级别的东西要好得多。但是,该级别的工具需要了解源语言及其字节码映射。 Scala是否存在类似的东西?
到目前为止,我已经可以将Javassist与Scala一起用于非常简单的事情,但是在其他一些事情上,我却被Scala / Java的某些差异所困扰。

I am looking for a high level bytecode manipulation tool like Javassist, but that understands some of Scala peculiarities. Lower level bytecode manipulation tools should be relatively agnostic, but for my use cases something at the level of Javassist is much better. However a tool at that level needs to know about the source language and its bytecode mapping. Does something like this exist for Scala? So far I have been able to use Javassist with Scala for very simple things, but I have been bitten by some Scala/Java differences for a couple of other things.

推荐答案

我认为尚不存在这样的工具。当前的情况是,您不能混合使用不同版本的Scala编译的编译单元,即,使用Scala 2.9编译的类不能与使用Scala 2.10编译的类互操作。

I don't think that such a tool exists (yet). The current situation is, that you cannot mix compilation units compiled with different versions of Scala, i.e. a class compiled with Scala 2.9 will not interoperate with a class compiled with Scala 2.10.

使用Scala 2.10时,可以使用斯卡拉反射 Scala宏可以达到与字节码修改相似的目标。对我来说,这似乎是最有前途的方法。

When you use Scala 2.10, you can use Scala reflection and Scala macros to reach similar goals as with bytecode modification. For me this looks like the most future proof way.

您的一个问题旨在添加序列号ID。使用Scala宏绝对应该可以做到这一点。使用Scala宏,甚至可以根据API的更改在外部数据库中管理序列版本ID。

One of your questions aimed at adding a serial version ID. This should definitely be possible with Scala macros. With Scala macros it shoudl even be possible to manage the serial version ids in an external database according to API changes.

这篇关于是否有像Javassist这样的Scala感知高级字节码操作工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆