Good link to how scala is displayed on jvm bytecode

Are there any good notes on how the Scala compiler maps various Scala functions to bytecode?

Quick google picked up background material from David Pollack's 2009 talk

https://github.com/dpp/jvm_summit_2009/blob/master/scala_fancy_pants.pdf

But I suspect that this may be either obsolete or incomplete.

I could try to collect this data myself using scalap javap, but it would be useful to capitalize on someone's efforts and insights.

+5
source share
2 answers

in Scala REPL, use :javap -cto see the generated bytecode.

For instance:

scala> class Bytes { def a = println("hello") }
defined class Bytes

scala> :javap -c Bytes
Compiled from "<console>"
public class Bytes extends java.lang.Object{
public void a();
  Code:
   0:   getstatic   #13; //Field scala/Predef$.MODULE$:Lscala/Predef$;
   3:   ldc #15; //String hello
   5:   invokevirtual   #19; //Method scala/Predef$.println:(Ljava/lang/Object;)V
   8:   return

public Bytes();
  Code:
   0:   aload_0
   1:   invokespecial   #24; //Method java/lang/Object."<init>":()V
   4:   return

}
+5
source

, . - , . , , -, ..

Sublime, .

+1

All Articles