SlideShare a Scribd company logo
1 of 76
Download to read offline
SCALA UNDER THE HOOD
TZOFIA SHIFTAN / OVEROPS
AGENDA
1. JVM 101
2. THE COOL STUFF
JVM 101
bytecode
Noun
Java bytecode is the instruction set of the
Java virtual machine
Wikipedia
JVM
Example.classExample.scala
scalac scala
javap
class file
javap
$ javap Example.class
Compiled from "Example.scala"
public class Example {
public int b();
public int bar(int);
public Example();
}
javap
$ javap -p Example.class
Compiled from "Example.scala"
public class Example {
private int a;
private final int b;
private int a();
private void a_$eq(int);
public int b();
private void foo();
public int bar(int);
public Example();
}
javap
$ javap -c Example.class
Compiled from "Example.scala"
public class Example {
public int b();
Code:
0: aload_0
1: getfield #21 // Field b:I
4: ireturn
public int bar(int);
Code:
0: iconst_3
1: iload_1
2: imul
3: ireturn
...
javap
JVM
THREADTHREAD THREAD
STACK STACK STACK
FRAME
FRAME
FRAME
FRAME
FRAME
FRAME
FRAME
FRAME
FRAME
FRAME
OPERAND STACKLOCAL VARIABLES
this
0 1 2
def add(a : Int, b : Int) = a+b
iload_0
iload_1
iadd
ireturn
add(2,5)
FRAME
LOCAL VARIABLES OPERAND STACK
a b
2 5
def add(a : Int, b : Int) = a+b
iload_0
iload_1
iadd
ireturn
add(2,5)
FRAME
LOCAL VARIABLES OPERAND STACK
a b
2 5
2
def add(a : Int, b : Int) = a+b
iload_0
iload_1
iadd
ireturn
add(2,5)
FRAME
LOCAL VARIABLES OPERAND STACK
a b
2 5
2
5
def add(a : Int, b : Int) = a+b
iload_0
iload_1
iadd
ireturn
add(2,5)
FRAME
LOCAL VARIABLES OPERAND STACK
a b
2 5
7
2
5
7
+
=
2
5
FRAME
LOCAL VARIABLES OPERAND STACK
a b
2 5
7
def add(a : Int, b : Int) = a+b
iload_0
iload_1
iadd
ireturn
add(2,5)
THE COOL STUFF
val vs var vs def
val
var
def
class Var {
var a = 1
}
class Val {
val a = 1
}
class Def {
def a = 1
}
javap -p Var
javap -p Val
javap -p Def
val
var
def
private final int a;
public int a();
public Val();
private int a;
public int a();
public void a_$eq(int);
public Var();
public int a();
public Def();
val
var
def
private final int a;
public int a();
public Val();
private int a;
public int a();
public void a_$eq(int);
public Var();
public int a();
public Def();
val
var
def
private final int a;
public int a();
public Val();
private int a;
public int a();
public void a_$eq(int);
public Var();
public int a();
public Def();
val
var
def
private final int a;
public int a();
public Val();
private int a;
public int a();
public void a_$eq(int);
public Var();
public int a();
public Def();
val
var
def
public int a();
aload_0
getfield #13 // Field a:I
ireturn
public int a();
iconst_1
ireturn
return this.a
return 1
val
var
def
private final int a;
public int a();
public Val();
private int a;
public int a();
public void a_$eq(int);
public Var();
public int a();
public Def();
val
var
def
public void a_$eq(int);
aload_0
iload_1
putfield #13 // Field a:I
return
this.a = a
val
var
def
private final int a;
public int a();
public Val();
private int a;
public int a();
public void a_$eq(int);
public Var();
public int a();
public Def();
val
var
def
public Va[r|l]();
aload_0
invokespecial #19 // Method java/lang/Object."<init>":()V
aload_0
iconst_1
putfield #13 // Field a:I
return
public Def();
aload_0
invokespecial #16 // Method java/lang/Object."<init>":()V
return
val
var
def
this.a = 1
return
getter setter evaluation
val 1
var 1
def multiple
lazy val
val
lazy val
class Val {
val a = 1
}
class LazyVal {
lazy val a = 1
}
javap -p Val
javap -p LazyVal
val
lazy val
private final int a;
public Val();
public int a();
private int a;
public LazyVal();
private volatile boolean bitmap$0;
private int a$lzycompute();
public int a();
val
lazy val
private final int a;
public Val();
public int a();
private int a;
public LazyVal();
private volatile boolean bitmap$0;
private int a$lzycompute();
public int a();
val
lazy val
private final int a;
public Val();
public int a();
private int a;
public LazyVal();
private volatile boolean bitmap$0;
private int a$lzycompute();
public int a();
val
lazy val
public Val();
aload_0
invokespecial #19 // Method java/lang/Object."<init>":()V
aload_0
iconst_1
putfield #13 // Field a:I
return
public LazyVal();
aload_0
Invokespecial #28 // Method java/lang/Object."<init>":()V
return
super()
val
lazy val
private final int a;
public Val();
public int a();
private int a;
public LazyVal();
private volatile boolean bitmap$0;
private int a$lzycompute();
public int a();
val
lazy val
private int a$lzycompute();
0: aload_0
1: dup
2: astore_1
3: monitorenter
4: aload_0
5: getfield #16 // Field bitmap$0:Z
8: ifne 21
11: aload_0
12: iconst_1
13: putfield #18 // Field a:I
16: aload_0
17: iconst_1
18: putfield #16 // Field bitmap$0:Z
21: aload_1
22: monitorexit
23: goto 29
26: aload_1
27: monitorexit
28: athrow
29: aload_0
30: getfield #18 // Field a:I
33: ireturn
private int a$lzycompute();
0: aload_0
1: dup
2: astore_1
3: monitorenter
4: aload_0
5: getfield #16 // Field bitmap$0:Z
8: ifne 21
11: aload_0
12: iconst_1
13: putfield #18 // Field a:I
16: aload_0
17: iconst_1
18: putfield #16 // Field bitmap$0:Z
21: aload_1
22: monitorexit
23: goto 29
26: aload_1
27: monitorexit
28: athrow
29: aload_0
30: getfield #18 // Field a:I
33: ireturn
synchronize start
private int a$lzycompute();
0: aload_0
1: dup
2: astore_1
3: monitorenter
4: aload_0
5: getfield #16 // Field bitmap$0:Z
8: ifne 21
11: aload_0
12: iconst_1
13: putfield #18 // Field a:I
16: aload_0
17: iconst_1
18: putfield #16 // Field bitmap$0:Z
21: aload_1
22: monitorexit
23: goto 29
26: aload_1
27: monitorexit
28: athrow
29: aload_0
30: getfield #18 // Field a:I
33: ireturn
bitmap$0 ? 0
private int a$lzycompute();
0: aload_0
1: dup
2: astore_1
3: monitorenter
4: aload_0
5: getfield #16 // Field bitmap$0:Z
8: ifne 21
11: aload_0
12: iconst_1
13: putfield #18 // Field a:I
16: aload_0
17: iconst_1
18: putfield #16 // Field bitmap$0:Z
21: aload_1
22: monitorexit
23: goto 29
26: aload_1
27: monitorexit
28: athrow
29: aload_0
30: getfield #18 // Field a:I
33: ireturn
this.a = 1
this.bitmap$0 = 1
synchronize end
return this.a
bitmap$0 == 0
private int a$lzycompute();
0: aload_0
1: dup
2: astore_1
3: monitorenter
4: aload_0
5: getfield #16 // Field bitmap$0:Z
8: ifne 21
11: aload_0
12: iconst_1
13: putfield #18 // Field a:I
16: aload_0
17: iconst_1
18: putfield #16 // Field bitmap$0:Z
21: aload_1
22: monitorexit
23: goto 29
26: aload_1
27: monitorexit
28: athrow
29: aload_0
30: getfield #18 // Field a:I
33: ireturn
synchronize end
return this.a
bitmap$0 == 1
private int a$lzycompute() {
LazyVal lazyVal = this;
synchronized (lazyVal) {
if (!this.bitmap$0) {
this.a = 1;
this.bitmap$0 = true;
}
}
return this.a;
}
private int a$lzycompute() {
LazyVal lazyVal = this;
synchronized (lazyVal) {
if (!this.bitmap$0) {
this.a = 1;
this.bitmap$0 = true;
}
}
return this.a;
}
private int a$lzycompute() {
LazyVal lazyVal = this;
synchronized (lazyVal) {
if (!this.bitmap$0) {
this.a = 1;
this.bitmap$0 = true;
}
}
return this.a;
}
private final int a;
public Val();
public int a();
private int a;
public LazyVal();
private volatile boolean bitmap$0;
private int a$lzycompute();
public int a();
val
lazy val
public int a();
0: aload_0
1: getfield #16 // Field bitmap$0:Z
4: ifne 14
7: aload_0
8: invokespecial #24 // Method a$lzycompute:()I
11: goto 18
14: aload_0
15: getfield #18 // Field a:I
18: ireturn
public int a();
0: aload_0
1: getfield #16 // Field bitmap$0:Z
4: ifne 14
7: aload_0
8: invokespecial #24 // Method a$lzycompute:()I
11: goto 18
14: aload_0
15: getfield #18 // Field a:I
18: ireturn
bitmap$0 ? 0
public int a();
0: aload_0
1: getfield #16 // Field bitmap$0:Z
4: ifne 14
7: aload_0
8: invokespecial #24 // Method a$lzycompute:()I
11: goto 18
14: aload_0
15: getfield #18 // Field a:I
18: ireturn
this.a$lzycompute()
return ^
bitmap$0 == 0
public int a();
0: aload_0
1: getfield #16 // Field bitmap$0:Z
4: ifne 14
7: aload_0
8: invokespecial #24 // Method a$lzycompute:()I
11: goto 18
14: aload_0
15: getfield #18 // Field a:I
18: ireturn
bitmap$0 == 1 return this.a
evaluation
val c’tor
lazy val lzycompute
object
object Hello {
def main(args: Array[String]) {
println("Hello, Scala Swarm!")
}
}
Hello.scala
Hello.class
Hello$.class
scalac
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
public static void main(java.lang.String[]);
getstatic #16 // Field Hello$.MODULE$:LHello$;
aload_0
invokevirtual #18 // Method Hello$.main:([Ljava/lang/String;)V
return
Hello$.MODULE$.main(args)
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
public static {};
new #2 // class Hello$
invokespecial #12 // Method "<init>":()V
return
new Hello$()
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
private Hello$();
aload_0
invokespecial #29 // Method java/lang/Object."<init>":()V
aload_0
putstatic #31 // Field MODULE$:LHello$;
return
MODULE$ = this
Compiled from "Hello.scala"
public final class Hello {
public static void main(java.lang.String[]);
}
Compiled from "Hello.scala"
public final class Hello$ {
public static Hello$ MODULE$;
public static {};
private Hello$();
public void main(java.lang.String[]);
}
public void main(java.lang.String[]);
getstatic #20 // Field scala/Predef$.MODULE$:Lscala/Predef$;
ldc #22 // String Hello, Scala Swarm!
invokevirtual #26 // Method scala/Predef$.println:(Ljava/lang/Object;)V
return
println(“Hello, Scala Swarm!”)
public final class Hello$ {
public static Hello$ MODULE$;
public static {
new Hello$();
}
private Hello$() {
MODULE$ = this;
}
public void main(String[] args) {
println("Hello, Scala Swarm!");
}
}
public final class Hello {
public static void main(final String[] args) {
Hello$.MODULE$.main(args);
}
}
public final class Hello$ {
public static Hello$ MODULE$;
public static {
new Hello$();
}
private Hello$() {
MODULE$ = this;
}
public void main(String[] args) {
println("Hello, Scala Swarm!");
}
}
public final class Hello {
public static void main(final String[] args) {
Hello$.MODULE$.main(args);
}
}
public final class Hello$ {
public static Hello$ MODULE$;
public static {
new Hello$();
}
private Hello$() {
MODULE$ = this;
}
public void main(String[] args) {
println("Hello, Scala Swarm!");
}
}
public final class Hello {
public static void main(final String[] args) {
Hello$.MODULE$.main(args);
}
}
public final class Hello$ {
public static Hello$ MODULE$;
public static {
new Hello$();
}
private Hello$() {
MODULE$ = this;
}
public void main(String[] args) {
println("Hello, Scala Swarm!");
}
}
public final class Hello {
public static void main(final String[] args) {
Hello$.MODULE$.main(args);
}
}
public final class Hello$ {
public static Hello$ MODULE$;
public static {
new Hello$();
}
private Hello$() {
MODULE$ = this;
}
public void main(String[] args) {
println(“Hello, Scala Swarm!");
}
}
public final class Hello {
public static void main(final String[] args) {
Hello$.MODULE$.main(args);
}
}
public final class Hello$ {
public static Hello$ MODULE$;
public static {
new Hello$();
}
private Hello$() {
MODULE$ = this;
}
public void main(String[] args) {
println("Hello, Scala Swarm!");
}
}
public final class Hello {
public static void main(final String[] args) {
Hello$.MODULE$.main(args);
}
}
Hello, Scala Swarm!
SUMMARY
Given a problem, consider the following steps:
1. javap
2. repeat
tzofia@overopshq.com
@tzofias

More Related Content

What's hot

Why you-dont-need-design-patterns-in-python
Why you-dont-need-design-patterns-in-pythonWhy you-dont-need-design-patterns-in-python
Why you-dont-need-design-patterns-in-pythonSivanagaraju Pachipulusu
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 
Zend VMにおける例外の実装
Zend VMにおける例外の実装Zend VMにおける例外の実装
Zend VMにおける例外の実装Yoshio Hanawa
 
HotSpot template interpreter memos
HotSpot template interpreter memosHotSpot template interpreter memos
HotSpot template interpreter memosytoshima
 
Common Intermediate Language (.NET) by Example
Common Intermediate Language (.NET) by ExampleCommon Intermediate Language (.NET) by Example
Common Intermediate Language (.NET) by ExampleGanesh Samarthyam
 
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)Ontico
 
Python 炒股指南
Python 炒股指南 Python 炒股指南
Python 炒股指南 Leo Zhou
 
節子、それViewControllerやない...、FatViewControllerや...。
節子、それViewControllerやない...、FatViewControllerや...。節子、それViewControllerやない...、FatViewControllerや...。
節子、それViewControllerやない...、FatViewControllerや...。Kenji Tanaka
 
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLABCOMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLABCarlos Buitron Quispe
 
Nobody knows-except-g4mm4
Nobody knows-except-g4mm4Nobody knows-except-g4mm4
Nobody knows-except-g4mm4Xchym Hiệp
 
VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法
VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法
VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法Kenji Tanaka
 
Ruby closures, how are they possible?
Ruby closures, how are they possible?Ruby closures, how are they possible?
Ruby closures, how are they possible?Carlos Alonso Pérez
 
Blending Culture in Twitter Client
Blending Culture in Twitter ClientBlending Culture in Twitter Client
Blending Culture in Twitter ClientKenji Tanaka
 
Catastrophic Cancellation
Catastrophic CancellationCatastrophic Cancellation
Catastrophic CancellationC4Media
 
NSClient++ Workshop: 05 Monitoring
NSClient++ Workshop: 05 MonitoringNSClient++ Workshop: 05 Monitoring
NSClient++ Workshop: 05 MonitoringMichael Medin
 

What's hot (18)

Why you-dont-need-design-patterns-in-python
Why you-dont-need-design-patterns-in-pythonWhy you-dont-need-design-patterns-in-python
Why you-dont-need-design-patterns-in-python
 
C lab programs
C lab programsC lab programs
C lab programs
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
Zend VMにおける例外の実装
Zend VMにおける例外の実装Zend VMにおける例外の実装
Zend VMにおける例外の実装
 
HotSpot template interpreter memos
HotSpot template interpreter memosHotSpot template interpreter memos
HotSpot template interpreter memos
 
Common Intermediate Language (.NET) by Example
Common Intermediate Language (.NET) by ExampleCommon Intermediate Language (.NET) by Example
Common Intermediate Language (.NET) by Example
 
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
Getting started with LLVM using Swift / Алексей Денисов (Blacklane)
 
Python 炒股指南
Python 炒股指南 Python 炒股指南
Python 炒股指南
 
節子、それViewControllerやない...、FatViewControllerや...。
節子、それViewControllerやない...、FatViewControllerや...。節子、それViewControllerやない...、FatViewControllerや...。
節子、それViewControllerやない...、FatViewControllerや...。
 
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLABCOMUNICACION SERIAL DSPIC30F3014 Y MATLAB
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
 
Nobody knows-except-g4mm4
Nobody knows-except-g4mm4Nobody knows-except-g4mm4
Nobody knows-except-g4mm4
 
VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法
VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法
VC「もしかして...」Model「私たち...」「「入れ替わってるー!?」」を前前前世から防ぐ方法
 
Ruby closures, how are they possible?
Ruby closures, how are they possible?Ruby closures, how are they possible?
Ruby closures, how are they possible?
 
Blending Culture in Twitter Client
Blending Culture in Twitter ClientBlending Culture in Twitter Client
Blending Culture in Twitter Client
 
Of class3
Of class3Of class3
Of class3
 
Catastrophic Cancellation
Catastrophic CancellationCatastrophic Cancellation
Catastrophic Cancellation
 
Vcs15
Vcs15Vcs15
Vcs15
 
NSClient++ Workshop: 05 Monitoring
NSClient++ Workshop: 05 MonitoringNSClient++ Workshop: 05 Monitoring
NSClient++ Workshop: 05 Monitoring
 

Similar to Scala Under the Hood / ScalaSwarm

ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdfANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdfanukoolelectronics
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesAndrey Karpov
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
The bytecode mumbo-jumbo
The bytecode mumbo-jumboThe bytecode mumbo-jumbo
The bytecode mumbo-jumboRaimon Ràfols
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Raimon Ràfols
 
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfInterfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfsutharbharat59
 
SOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean ArchitectureSOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean ArchitectureFabio Collini
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfaquadreammail
 
Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]David Buck
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RADScottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RADlostcaggy
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxcurwenmichaela
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHPSharon Levy
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfmichardsonkhaicarr37
 
import java.util.Scanner;public class Fraction {   instan.pdf
import java.util.Scanner;public class Fraction {    instan.pdfimport java.util.Scanner;public class Fraction {    instan.pdf
import java.util.Scanner;public class Fraction {   instan.pdfapleathers
 

Similar to Scala Under the Hood / ScalaSwarm (20)

ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdfANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
 
Best Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' MistakesBest Bugs from Games: Fellow Programmers' Mistakes
Best Bugs from Games: Fellow Programmers' Mistakes
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
The bytecode mumbo-jumbo
The bytecode mumbo-jumboThe bytecode mumbo-jumbo
The bytecode mumbo-jumbo
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014
 
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdfInterfacepackage PJ1; public interface SimpleFractionInterface.pdf
Interfacepackage PJ1; public interface SimpleFractionInterface.pdf
 
SOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean ArchitectureSOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean Architecture
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
 
Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
 
Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RADScottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RAD
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHP
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdf
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
 
import java.util.Scanner;public class Fraction {   instan.pdf
import java.util.Scanner;public class Fraction {    instan.pdfimport java.util.Scanner;public class Fraction {    instan.pdf
import java.util.Scanner;public class Fraction {   instan.pdf
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 

Recently uploaded

Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Recently uploaded (20)

Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Scala Under the Hood / ScalaSwarm

  • 1. SCALA UNDER THE HOOD TZOFIA SHIFTAN / OVEROPS
  • 2.
  • 3. AGENDA 1. JVM 101 2. THE COOL STUFF
  • 5. bytecode Noun Java bytecode is the instruction set of the Java virtual machine Wikipedia
  • 8. $ javap Example.class Compiled from "Example.scala" public class Example { public int b(); public int bar(int); public Example(); } javap
  • 9. $ javap -p Example.class Compiled from "Example.scala" public class Example { private int a; private final int b; private int a(); private void a_$eq(int); public int b(); private void foo(); public int bar(int); public Example(); } javap
  • 10. $ javap -c Example.class Compiled from "Example.scala" public class Example { public int b(); Code: 0: aload_0 1: getfield #21 // Field b:I 4: ireturn public int bar(int); Code: 0: iconst_3 1: iload_1 2: imul 3: ireturn ... javap
  • 11. JVM THREADTHREAD THREAD STACK STACK STACK FRAME FRAME FRAME FRAME FRAME FRAME FRAME FRAME FRAME
  • 13. def add(a : Int, b : Int) = a+b iload_0 iload_1 iadd ireturn add(2,5) FRAME LOCAL VARIABLES OPERAND STACK a b 2 5
  • 14. def add(a : Int, b : Int) = a+b iload_0 iload_1 iadd ireturn add(2,5) FRAME LOCAL VARIABLES OPERAND STACK a b 2 5 2
  • 15. def add(a : Int, b : Int) = a+b iload_0 iload_1 iadd ireturn add(2,5) FRAME LOCAL VARIABLES OPERAND STACK a b 2 5 2 5
  • 16. def add(a : Int, b : Int) = a+b iload_0 iload_1 iadd ireturn add(2,5) FRAME LOCAL VARIABLES OPERAND STACK a b 2 5 7 2 5 7 + = 2 5
  • 17. FRAME LOCAL VARIABLES OPERAND STACK a b 2 5 7 def add(a : Int, b : Int) = a+b iload_0 iload_1 iadd ireturn add(2,5)
  • 19. val vs var vs def
  • 20. val var def class Var { var a = 1 } class Val { val a = 1 } class Def { def a = 1 }
  • 21. javap -p Var javap -p Val javap -p Def val var def
  • 22. private final int a; public int a(); public Val(); private int a; public int a(); public void a_$eq(int); public Var(); public int a(); public Def(); val var def
  • 23. private final int a; public int a(); public Val(); private int a; public int a(); public void a_$eq(int); public Var(); public int a(); public Def(); val var def
  • 24. private final int a; public int a(); public Val(); private int a; public int a(); public void a_$eq(int); public Var(); public int a(); public Def(); val var def
  • 25. private final int a; public int a(); public Val(); private int a; public int a(); public void a_$eq(int); public Var(); public int a(); public Def(); val var def
  • 26. public int a(); aload_0 getfield #13 // Field a:I ireturn public int a(); iconst_1 ireturn return this.a return 1 val var def
  • 27. private final int a; public int a(); public Val(); private int a; public int a(); public void a_$eq(int); public Var(); public int a(); public Def(); val var def
  • 28. public void a_$eq(int); aload_0 iload_1 putfield #13 // Field a:I return this.a = a val var def
  • 29. private final int a; public int a(); public Val(); private int a; public int a(); public void a_$eq(int); public Var(); public int a(); public Def(); val var def
  • 30. public Va[r|l](); aload_0 invokespecial #19 // Method java/lang/Object."<init>":()V aload_0 iconst_1 putfield #13 // Field a:I return public Def(); aload_0 invokespecial #16 // Method java/lang/Object."<init>":()V return val var def this.a = 1 return
  • 31. getter setter evaluation val 1 var 1 def multiple
  • 33. val lazy val class Val { val a = 1 } class LazyVal { lazy val a = 1 }
  • 34. javap -p Val javap -p LazyVal val lazy val
  • 35. private final int a; public Val(); public int a(); private int a; public LazyVal(); private volatile boolean bitmap$0; private int a$lzycompute(); public int a(); val lazy val
  • 36. private final int a; public Val(); public int a(); private int a; public LazyVal(); private volatile boolean bitmap$0; private int a$lzycompute(); public int a(); val lazy val
  • 37. private final int a; public Val(); public int a(); private int a; public LazyVal(); private volatile boolean bitmap$0; private int a$lzycompute(); public int a(); val lazy val
  • 38. public Val(); aload_0 invokespecial #19 // Method java/lang/Object."<init>":()V aload_0 iconst_1 putfield #13 // Field a:I return public LazyVal(); aload_0 Invokespecial #28 // Method java/lang/Object."<init>":()V return super() val lazy val
  • 39. private final int a; public Val(); public int a(); private int a; public LazyVal(); private volatile boolean bitmap$0; private int a$lzycompute(); public int a(); val lazy val
  • 40. private int a$lzycompute(); 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: aload_0 5: getfield #16 // Field bitmap$0:Z 8: ifne 21 11: aload_0 12: iconst_1 13: putfield #18 // Field a:I 16: aload_0 17: iconst_1 18: putfield #16 // Field bitmap$0:Z 21: aload_1 22: monitorexit 23: goto 29 26: aload_1 27: monitorexit 28: athrow 29: aload_0 30: getfield #18 // Field a:I 33: ireturn
  • 41. private int a$lzycompute(); 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: aload_0 5: getfield #16 // Field bitmap$0:Z 8: ifne 21 11: aload_0 12: iconst_1 13: putfield #18 // Field a:I 16: aload_0 17: iconst_1 18: putfield #16 // Field bitmap$0:Z 21: aload_1 22: monitorexit 23: goto 29 26: aload_1 27: monitorexit 28: athrow 29: aload_0 30: getfield #18 // Field a:I 33: ireturn synchronize start
  • 42. private int a$lzycompute(); 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: aload_0 5: getfield #16 // Field bitmap$0:Z 8: ifne 21 11: aload_0 12: iconst_1 13: putfield #18 // Field a:I 16: aload_0 17: iconst_1 18: putfield #16 // Field bitmap$0:Z 21: aload_1 22: monitorexit 23: goto 29 26: aload_1 27: monitorexit 28: athrow 29: aload_0 30: getfield #18 // Field a:I 33: ireturn bitmap$0 ? 0
  • 43. private int a$lzycompute(); 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: aload_0 5: getfield #16 // Field bitmap$0:Z 8: ifne 21 11: aload_0 12: iconst_1 13: putfield #18 // Field a:I 16: aload_0 17: iconst_1 18: putfield #16 // Field bitmap$0:Z 21: aload_1 22: monitorexit 23: goto 29 26: aload_1 27: monitorexit 28: athrow 29: aload_0 30: getfield #18 // Field a:I 33: ireturn this.a = 1 this.bitmap$0 = 1 synchronize end return this.a bitmap$0 == 0
  • 44. private int a$lzycompute(); 0: aload_0 1: dup 2: astore_1 3: monitorenter 4: aload_0 5: getfield #16 // Field bitmap$0:Z 8: ifne 21 11: aload_0 12: iconst_1 13: putfield #18 // Field a:I 16: aload_0 17: iconst_1 18: putfield #16 // Field bitmap$0:Z 21: aload_1 22: monitorexit 23: goto 29 26: aload_1 27: monitorexit 28: athrow 29: aload_0 30: getfield #18 // Field a:I 33: ireturn synchronize end return this.a bitmap$0 == 1
  • 45. private int a$lzycompute() { LazyVal lazyVal = this; synchronized (lazyVal) { if (!this.bitmap$0) { this.a = 1; this.bitmap$0 = true; } } return this.a; }
  • 46. private int a$lzycompute() { LazyVal lazyVal = this; synchronized (lazyVal) { if (!this.bitmap$0) { this.a = 1; this.bitmap$0 = true; } } return this.a; }
  • 47. private int a$lzycompute() { LazyVal lazyVal = this; synchronized (lazyVal) { if (!this.bitmap$0) { this.a = 1; this.bitmap$0 = true; } } return this.a; }
  • 48. private final int a; public Val(); public int a(); private int a; public LazyVal(); private volatile boolean bitmap$0; private int a$lzycompute(); public int a(); val lazy val
  • 49. public int a(); 0: aload_0 1: getfield #16 // Field bitmap$0:Z 4: ifne 14 7: aload_0 8: invokespecial #24 // Method a$lzycompute:()I 11: goto 18 14: aload_0 15: getfield #18 // Field a:I 18: ireturn
  • 50. public int a(); 0: aload_0 1: getfield #16 // Field bitmap$0:Z 4: ifne 14 7: aload_0 8: invokespecial #24 // Method a$lzycompute:()I 11: goto 18 14: aload_0 15: getfield #18 // Field a:I 18: ireturn bitmap$0 ? 0
  • 51. public int a(); 0: aload_0 1: getfield #16 // Field bitmap$0:Z 4: ifne 14 7: aload_0 8: invokespecial #24 // Method a$lzycompute:()I 11: goto 18 14: aload_0 15: getfield #18 // Field a:I 18: ireturn this.a$lzycompute() return ^ bitmap$0 == 0
  • 52. public int a(); 0: aload_0 1: getfield #16 // Field bitmap$0:Z 4: ifne 14 7: aload_0 8: invokespecial #24 // Method a$lzycompute:()I 11: goto 18 14: aload_0 15: getfield #18 // Field a:I 18: ireturn bitmap$0 == 1 return this.a
  • 55. object Hello { def main(args: Array[String]) { println("Hello, Scala Swarm!") } }
  • 57. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 58. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 59. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 60. public static void main(java.lang.String[]); getstatic #16 // Field Hello$.MODULE$:LHello$; aload_0 invokevirtual #18 // Method Hello$.main:([Ljava/lang/String;)V return Hello$.MODULE$.main(args)
  • 61. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 62. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 63. public static {}; new #2 // class Hello$ invokespecial #12 // Method "<init>":()V return new Hello$()
  • 64. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 65. private Hello$(); aload_0 invokespecial #29 // Method java/lang/Object."<init>":()V aload_0 putstatic #31 // Field MODULE$:LHello$; return MODULE$ = this
  • 66. Compiled from "Hello.scala" public final class Hello { public static void main(java.lang.String[]); } Compiled from "Hello.scala" public final class Hello$ { public static Hello$ MODULE$; public static {}; private Hello$(); public void main(java.lang.String[]); }
  • 67. public void main(java.lang.String[]); getstatic #20 // Field scala/Predef$.MODULE$:Lscala/Predef$; ldc #22 // String Hello, Scala Swarm! invokevirtual #26 // Method scala/Predef$.println:(Ljava/lang/Object;)V return println(“Hello, Scala Swarm!”)
  • 68. public final class Hello$ { public static Hello$ MODULE$; public static { new Hello$(); } private Hello$() { MODULE$ = this; } public void main(String[] args) { println("Hello, Scala Swarm!"); } } public final class Hello { public static void main(final String[] args) { Hello$.MODULE$.main(args); } }
  • 69. public final class Hello$ { public static Hello$ MODULE$; public static { new Hello$(); } private Hello$() { MODULE$ = this; } public void main(String[] args) { println("Hello, Scala Swarm!"); } } public final class Hello { public static void main(final String[] args) { Hello$.MODULE$.main(args); } }
  • 70. public final class Hello$ { public static Hello$ MODULE$; public static { new Hello$(); } private Hello$() { MODULE$ = this; } public void main(String[] args) { println("Hello, Scala Swarm!"); } } public final class Hello { public static void main(final String[] args) { Hello$.MODULE$.main(args); } }
  • 71. public final class Hello$ { public static Hello$ MODULE$; public static { new Hello$(); } private Hello$() { MODULE$ = this; } public void main(String[] args) { println("Hello, Scala Swarm!"); } } public final class Hello { public static void main(final String[] args) { Hello$.MODULE$.main(args); } }
  • 72. public final class Hello$ { public static Hello$ MODULE$; public static { new Hello$(); } private Hello$() { MODULE$ = this; } public void main(String[] args) { println(“Hello, Scala Swarm!"); } } public final class Hello { public static void main(final String[] args) { Hello$.MODULE$.main(args); } }
  • 73. public final class Hello$ { public static Hello$ MODULE$; public static { new Hello$(); } private Hello$() { MODULE$ = this; } public void main(String[] args) { println("Hello, Scala Swarm!"); } } public final class Hello { public static void main(final String[] args) { Hello$.MODULE$.main(args); } }
  • 75. SUMMARY Given a problem, consider the following steps: 1. javap 2. repeat