Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there Scala aware high level byte-code manipulation tool like Javassist?

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.

like image 954
Daniel Mahler Avatar asked Jul 08 '13 21:07

Daniel Mahler


1 Answers

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.

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.

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.

like image 63
stefan.schwetschke Avatar answered Oct 29 '22 18:10

stefan.schwetschke