Following Scala mailing lists, different people often say: "compiler rewrites this [scala] code into this [java/scala??] code". For example, from one of the latest threads, if Scala sees
class C(i: Int = 4) { ... }
then the compiler rewrites this as (effectively):
class C(i: Int) { ... }
object C {
def init$default$1: Int = 4
}
How can I find out, what will be the compiler output for my code? Should I decompile the resulting bytecode for that?
One can look at the generated bytecode with
You can use "-print" as compiler option, and scalac will remove all Scala-specific features.
For example, here is the original code:
And if you use "scalac -print" to compile it, you will get the following Scala code.