SlideShare a Scribd company logo
JVM bytecode

The secret language behind Java and Scala
About Me

Writing code for the past ~15 years.

     1. Dev at IDF intl

    2. Team lead, architect at IAI Space Industries

    3. CEO at VisualTao

    4. Director - AutoCAD Web & Mobile, GM Autodesk IL

    5. CEO at Takipi
Overview

1. What is bytecode

2. The 3 biggest differences between source code and bytecode

3. 5 things you should know about bytecode

4. Practical uses
What is bytecode?


A set of low-level instructions to be executed by the JVM.

~200 instruction types, each ~1-2 bytes in size.

Some instructions are very similar to Java, some completely
different.
Bytecode is very similar to Assembly
(That’s why we avoid it…)



                 assembly - > exec file -> OS

                 bytecode -> .class file -> JVM




              .cpp -> g++     -> exec file -> OS

              .java -> JavaC -> .class file -> JVM

              .scala-> ScalaC -> .class file -> JVM
The 3 biggest differences between
source and byte code
1. No variables



Bytecode employs an Assembly-like register stack
known as the locals stack to hold variables.

Values of fields, functions and of binary operations (+, -, * ..) are held in a
stack known as the operand stack.
public getField() : double
                                                   L0
public class LocalVars                              ALOAD 0: this
{                                                   GETFIELD NoLocalVars.state : boolean
     private int intField;                          IFEQ L1
     private double doubleField;                   L2
                                                    ALOAD 0: this
     private boolean state;                         GETFIELD NoLocalVars.intField : int
                                                    ICONST_1
     public double getField()                       IADD
     {                                              ISTORE 1
            if (state)                             L3
            {                                       GETSTATIC System.out : PrintStream
                                                    ILOAD 1: a
                   int a = intField + 1;
                                                    INVOKEVIRTUAL PrintStream.println(int) : void
                   return a;
                                                   L4
            }                                       ILOAD 1: a
            else                                    I2D
            {                                       DRETURN
                   double b = doubleField + 1;     L1
                   return b;                        ALOAD 0: this
            }                                       GETFIELD NoLocalVars.doubleField : double
     }                                              DCONST_1
}                                                   DADD
                                                    DSTORE 1
                                                   L5
                                                    GETSTATIC System.out : PrintStream
                                                    DLOAD 1: b
Notes
                                                    INVOKEVIRTUAL PrintStream.println(double) : void
                                                   L6
Notice how the same register slot (1) is            DLOAD 1: b
re-used between blocks for different variables.     DRETURN
                                                   L7
The variable meta-data table describes the          LOCALVARIABLE this NoLocalVars L0 L7 0
mappings between registers and source code          LOCALVARIABLE a int L3 L1 1
variables                                           LOCALVARIABLE b double L5 L7 1
                                                    MAXSTACK = 4
                                                    MAXLOCALS = 3
2. No binary logical operators



No built-in support for &&, ||, ^

Compilers implement these using jump instructions.
public and(boolean, boolean) : void
 public class NoLogicalOperators
                                                    L0
 {                                                   ILOAD 1: a
   public void and(boolean a, boolean b) {           IFEQ L1
     if (a && b) {                                   ILOAD 2: b
        System.out.println("its true");              IFEQ L1
      }                                             L2
   }                                                 GETSTATIC System.out : PrintStream
                                                     LDC "its true"
     public void or(boolean a, boolean b) {          INVOKEVIRTUAL PrintStream.println(String) : void
       if (a || b) {                                L1
         System.out.println("its true");             RETURN
                                                    L3
       }
     }
 }
                                                   public or(boolean, boolean) : void
                                                    L0
                                                     ILOAD 1: a
                                                     IFNE L1
                                                     ILOAD 2: b
                                                     IFEQ L2
                                                    L1
                                                     GETSTATIC System.out : PrintStream
Notes                                                LDC "its true"
                                                     INVOKEVIRTUAL PrintStream.println(String) : void
Notice how both && and || operators are             L2
implemented using jump instructions who evaluate     RETURN
the last value if the operand stack                 L3
public class NoLogicalOperators                  public orX2(boolean, boolean, boolean, boolean) : void
{                                                 L0
  public void orX2(boolean a, boolean b,           ILOAD 1: a
    boolean c, boolean d) {                        IFNE L1
    if ((a || b) && (c || d))                      ILOAD 2: b
    {                                              IFEQ L2
      System.out.println("its true");             L1
    }                                              ILOAD 3: c
  }                                                IFNE L3
}                                                  ILOAD 4: d
                                                   IFEQ L2
                                                  L3
                                                   GETSTATIC System.out : PrintStream
                                                   LDC "its true"
                                                   INVOKEVIRTUAL PrintStream.println(String) : void
                                                  L2
                                                   RETURN
                                                  L4
Notes

For composite ||, && conditions compilers will
generate multiple jump combinations
3. No loop constructs



There’s no built-in support for while, for, for-each loops.

Compilers implement these using jump instructions.
public class Loops                                  public forLoop(int) : void
 {                                                    L0
   public void forLoop(int n) {                        ICONST_0
     for (int i = 0; i < n; i++) {                     ISTORE 2
       System.out.println(i);                         L1
     }                                                 GOTO L2
   }                                                  L3
 }                                                     GETSTATIC System.out : PrintStream
                                                       ILOAD 2: i
                                                       INVOKEVIRTUAL PrintStream.println(int) : void
                                                      L4
                                                       IINC 2: i 1
                                                      L2
                                                       ILOAD 2: i
                                                       ILOAD 1: n
                                                       IF_ICMPLT L3
                                                      L5
                                                       RETURN
                                                      L6
                                                       LOCALVARIABLE this Loops L0 L6 0
                                                       LOCALVARIABLE n int L0 L6 1
                                                       LOCALVARIABLE i int L1 L5 2



Notes

A for loop is implemented using a conditional jump
instruction comparing i and n
public class Loops                                   public whileLoop(int) : void
 {                                                     L0
   public void whileLoop(int n)                         ICONST_0
   {                                                    ISTORE 2
     int i = 0;                                        L1
                                                        GOTO L2
         while (i < n)                                 L3
         {                                              GETSTATIC System.out : PrintStream
           System.out.println(i);                       ILOAD 2: i
           i++;                                         INVOKEVIRTUAL PrintStream.println(int) : void
         }                                             L4
     }                                                  IINC 2: i 1
 }                                                     L2
                                                        ILOAD 2: i
                                                        ILOAD 1: n
                                                        IF_ICMPLT L3
                                                       L5
                                                        RETURN
                                                       L6
                                                        LOCALVARIABLE this Loops L0 L6 0
                                                        LOCALVARIABLE n int L0 L6 1
                                                        LOCALVARIABLE i int L1 L6 2

Notes

This while loop is also implemented using a
conditional jump instruction comparing i and n. The
bytecode is nearly identical to the previous loop.
public class Loops
 {                                                    public forEachLoop(List) : void
   public void forEachLoop(List<String> strings) {      L0
     for (String s : strings) {                          ALOAD 1: strings
       System.out.println(s);                            INVOKEINTERFACE List.iterator() : Iterator
     }                                                   ASTORE 3
   }                                                     GOTO L1
 }                                                      L2
                                                         ALOAD 3
                                                         INVOKEINTERFACE Iterator.next() : Object
                                                         CHECKCAST String
                                                         ASTORE 2
                                                        L3
                                                         GETSTATIC System.out : PrintStream
                                                         ALOAD 2: s
                                                         INVOKEVIRTUAL PrintStream.println(String) : void
                                                        L1
                                                         ALOAD 3
                                                         INVOKEINTERFACE Iterator.hasNext() : boolean
                                                         IFNE L2
                                                        L4
                                                         RETURN
                                                        L5
                                                         LOCALVARIABLE this Loops L0 L5 0
                                                         LOCALVARIABLE strings List L0 L5 1
Notes                                                     // declaration: java.util.List<java.lang.String>
                                                         LOCALVARIABLE s String L3 L1 2
A for-each loop is generated by the javaC compiler    }
by jumping against the hasNext() method. The result
bytecode is unaware of the for-each construct.

Also notice how register 3 is used to hold the
iterator
5 Things you should know about bytecode
  that affect everyday programming
1. No String support


Like in C, there’s no built-in support for strings, only char arrays.

Compilers usually use StringBuilder to compensate.

No penalty for concatenating different data types
public class ImplicitStrings                      // access flags 0x1
 {                                                  public toString(int, int) : String
   public String toString(int a, int b)              L0
   {                                                  NEW StringBuilder
                                                      DUP
     String c = "Hello " + a + "World" + b;
                                                      LDC "Hello "
     return c;
                                                      INVOKESPECIAL StringBuilder.<init>(String) : void
   }                                                  ILOAD 1: a
 }                                                    INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder
                                                      LDC "World"
                                                      INVOKEVIRTUAL StringBuilder.append(String) : StringBuilder
                                                      ILOAD 2: b
                                                      INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder
                                                      INVOKEVIRTUAL StringBuilder.toString() : String
                                                      ASTORE 3
                                                     L1
                                                      ALOAD 3: c
                                                      ARETURN
                                                     L2
                                                      LOCALVARIABLE this ImplicitStrings L0 L2 0
                                                      LOCALVARIABLE a int L0 L2 1
                                                      LOCALVARIABLE b int L0 L2 2
                                                      LOCALVARIABLE c String L1 L2 3


Notes

JavaC uses java.lang.StringBuilder to combine
(+)strings. Different overloads of the .append()
method are used to concat different data types.
public toString1(int, int) : String
  public class ImplicitStrings                          L0
  {                                                      NEW StringBuilder
    public String toString1(int a, int b)                DUP
    {                                                    LDC "Hello"
      String c;                                          INVOKESPECIAL StringBuilder.<init>(String) : void
                                                         ILOAD 1: a
                                                         INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder
          c = "Hello" + a;
                                                         INVOKEVIRTUAL StringBuilder.toString() : String
          c += "World" + b;                              ASTORE 3
                                                        L1
          return c;                                      NEW StringBuilder
      }                                                  DUP
  }                                                      ALOAD 3: c
                                                         INVOKESTATIC String.valueOf(Object) : String
                                                         INVOKESPECIAL StringBuilder.<init>(String) : void
                                                         LDC "World"
                                                         INVOKEVIRTUAL StringBuilder.append(String) : StringBuilder
                                                         ILOAD 2: b
                                                         INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder
                                                         INVOKEVIRTUAL StringBuilder.toString() : String
                                                         ASTORE 3: c
                                                        L2
                                                         ALOAD 3: c
                                                         ARETURN
                                                        L3

Notes

While this code is identical to the previous example
in terms of functionality, there’s a performance
penalty to note as 2 StringBuilders are constructed
2. Only 4 primitive types


Bytecode only operates on 4 primitives types ( int, float, double, long)
vs. the 8 Java primitives.

Doesn’t operate on char, bool, byte, short (treated as ints)
public mulByeShort(byte, short) : void
public class BytecodePrimitives                         L0
{                                                        GETSTATIC System.out : PrintStream
  public void mulByeShort(byte b, short c)               ILOAD 1: b
  {                                                      ILOAD 2: c
    System.out.println(b * c);                           IMUL
  }                                                      INVOKEVIRTUAL PrintStream.println(int) : void
                                                        L1
    public void mulInts(int b, int c)                    RETURN
    {                                                   L2
                                                         LOCALVARIABLE this B_BytecodePrimitives L0 L2 0
      System.out.println(b * c);
                                                         LOCALVARIABLE b byte L0 L2 1
    }
                                                         LOCALVARIABLE c short L0 L2 2
}
                                                       public mulInts(int, int) : void
                                                        L0
                                                         GETSTATIC System.out : PrintStream
                                                         ILOAD 1: b
                                                         ILOAD 2: c
                                                         IMUL
                                                         INVOKEVIRTUAL PrintStream.println(int) : void
                                                        L1
                                                         RETURN
                                                        L2
                                                         LOCALVARIABLE this B_BytecodePrimitives L0 L2 0
                                                         LOCALVARIABLE b int L0 L2 1
                                                         LOCALVARIABLE c int L0 L2 2
Notes

Notice how the bytecode for these 2 methods is
identical, regardless of the difference in var types
public class BytecodePrimitives                   public printIfTrue(boolean) : void
  {                                                  L0
    public void printIfTrue(boolean b)                ILOAD 1: b
    {                                                 IFEQ L1
                                                     L2
      if (b)
                                                      GETSTATIC System.out : PrintStream
      {
                                                      LDC "Hi"
        System.out.println("Hi");                     INVOKEVIRTUAL PrintStream.println(String) : void
      }                                              L1
    }                                                 RETURN
                                                     L3
      public void printIfN0(int i)                    LOCALVARIABLE this B_BytecodePrimitives L0 L3 0
      {                                               LOCALVARIABLE b boolean L0 L3 1
        if (i != 0)
        {                                           public printIfN0(int) : void
          System.out.println("Hi");                  L0
                                                      ILOAD 1: i
        }
                                                      IFEQ L1
      }
                                                     L2
  }                                                   GETSTATIC System.out : PrintStream
                                                      LDC "Hi"
                                                      INVOKEVIRTUAL PrintStream.println(String) : void
                                                     L1
                                                      RETURN
                                                     L3
                                                      LOCALVARIABLE this B_BytecodePrimitives L0 L3 0
Notes
                                                      LOCALVARIABLE i int L0 L3 1
The same observation is also true when evaluating
conditions. See how both boolean and int
operations are treated the same.
3. Using nested classes?


Compilers will add synthetic $this fields.

If you’re not making calls to your outer-class - don’t forget to add a static
modifier.
public class C_NestedClasses
   public class NestedClasses
                                                     {
   {                                                   public class C_NestedClasses$NestedClass
     public class NestedClass                          {
     {                                                   final C_NestedClasses this$0
     }
                                                         public <init>(C_NestedClasses) : void
        public static class StaticNestedClass            L0
        {                                                 ALOAD 0: this
                                                          ALOAD 1
        }                                                 PUTFIELD C_NestedClasses$NestedClass.this$0 : C_NestedClasses
                                                          ALOAD 0: this
   }
                                                          INVOKESPECIAL Object.<init>() : void
                                                          RETURN
                                                         L1
                                                          LOCALVARIABLE this C_NestedClasses$NestedClass L0 L1 0

                                                     }

                                                         public class C_NestedClasses$StaticNestedClass
                                                         {
                                                           public <init>() : void
                                                           L0
                                                            ALOAD 0: this
                                                            INVOKESPECIAL Object.<init>() : void
Notes                                                       RETURN
                                                           L1
The NestedClass inner-class has an implicit $this0
created for him, and assigned in the constructor.    }
Using nested classes (2)?


Try and avoid implicitly creating bridge methods by invoking
private members (use protected)
static access$0(D_BridgeMethods) : int
    public class BridgeMethods
                                                        L0
    {
                                                         ALOAD 0
      private int member;                                GETFIELD D_BridgeMethods.member : int
                                                         IRETURN
        public class BridgeMethodClass                   MAXSTACK = 1
        {                                                MAXLOCALS = 1
          public void printBridge()
          {                                            public printBridge() : void
            System.out.println(member);                 L0
          }                                              GETSTATIC System.out : PrintStream
        }                                                ALOAD 0: this
                                                         GETFIELD D_BridgeMethods$BridgeMethodClass.this$0 : D_BridgeMethods
    }
                                                         INVOKESTATIC D_BridgeMethods.access$0(D_BridgeMethods) : int
                                                         INVOKEVIRTUAL PrintStream.println(int) : void
                                                        L1
                                                         RETURN
                                                        L2
                                                         LOCALVARIABLE this D_BridgeMethods$BridgeMethodClass L0 L2 0




Notes

When a private field or method is invoked javaC will
add synthetic bridge methods to allow the internal
class to access private members of its outer-class
4. Boxing and unboxing


Boxing is added by the Java/Scala compiler.

There’s no such concept in bytecode or in the JVM.

Watch out for NullPointerExceptions
public printSqr(int) : void
                                                   L0
                                                    ILOAD 1: a
                                                    ISTORE 2
  public class Boxing
                                                   L1
  {                                                 ILOAD 1: a
    public void printSqr(int a)                     INVOKESTATIC Integer.valueOf(int) : Integer
    {                                               ASTORE 3
      int a1 = a;                                  L2
                                                    GETSTATIC System.out : PrintStream
        Integer a2 = a;                             ILOAD 2: a1
                                                    ALOAD 3: a2
        System.out.println(a1 * a2);                INVOKEVIRTUAL Integer.intValue() : int
  }                                                 IMUL
                                                    INVOKEVIRTUAL PrintStream.println(int) : void
                                                   L3
      public void check(Integer i)
                                                    RETURN
      {                                            L4
        if (i == 0)                                 LOCALVARIABLE this E_Boxing L0 L4 0
        {                                           LOCALVARIABLE a int L0 L4 1
          System.out.println("zero");               LOCALVARIABLE a1 int L1 L4 2
        }                                           LOCALVARIABLE a2 Integer L2 L4 3
      }
  }                                               public check(Integer) : void
                                                    L0
                                                     ALOAD 1: i
                                                     INVOKEVIRTUAL Integer.intValue() : int
                                                     IFNE L1
                                                    L2
Notes                                                GETSTATIC System.out : PrintStream
                                                     LDC "zero"
Notice how javaC implicitly invokes the various      INVOKEVIRTUAL PrintStream.println(String) : void
java.lang.Integer methods.                          L1
                                                     RETURN
Other compilers, such as scalaC, use their own      L3
                                                     LOCALVARIABLE this E_Boxing L0 L3 0
boxed types
                                                     LOCALVARIABLE i Integer L0 L3 1
                                                  }
5. 3 bytecode myths


1. Bytecode supports multiple inheritance

2. Illegal bytecode can crash the JVM (it’s blocked by the JVM verifier)

3. Low-level bytecode can operate outside the JVM sandbox
3 Main bytecode uses


1.   Building a compiler

2.   Static analysis

3.   JVM bytecode instrumentation
Building a “better Java” through Scala and ScalaC.


A new OO/functional language which compiles into
standard JVM bytecode.


Transparent from the JVM’s perspective.
Takipi - Overview

Explain the cause of server exceptions, latency and unexpected code behavior
at scale.

Help R&D teams solve errors and downtime in production systems, without
having to re-deploy code or sift through log files.
Takipi & bytecode


1. Index bytecode in the cloud.

2. When an exception occurs, query the DB to understand which variables,
   fields and conditions are causing it.

3. Instrument new bytecode to log the values causing the exception.

4. Present a “story” of the exception to the developer.
Thanks!
Join our private beta - takipi.com/signup


                tal.weiss@takipi.com




     @takipid (tweeting about Java, Scala, DevOps and Cloud)

More Related Content

What's hot (20)

Ec1201
Ec1201Ec1201
Ec1201
selvarajsbmece
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lv
Anton Arhipov
 
Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015
Raimon Ràfols
 
Assembler
AssemblerAssembler
Assembler
Mohd Arif
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
Linaro
 
Java 14 features
Java 14 featuresJava 14 features
Java 14 features
Aditi Anand
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
VandanaPagar1
 
The bytecode gobbledygook
The bytecode gobbledygookThe bytecode gobbledygook
The bytecode gobbledygook
Raimon Ràfols
 
Alp 05
Alp 05Alp 05
Alp 05
gswapnil86
 
Assembler (2)
Assembler (2)Assembler (2)
Assembler (2)
Vaibhav Bajaj
 
HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4
Linaro
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
Erhan Bagdemir
 
Introduction to Erlang Part 1
Introduction to Erlang Part 1Introduction to Erlang Part 1
Introduction to Erlang Part 1
Dmitry Zinoviev
 
Introduction to Erlang Part 2
Introduction to Erlang Part 2Introduction to Erlang Part 2
Introduction to Erlang Part 2
Dmitry Zinoviev
 
Developing android apps with java 8
Developing android apps with java 8Developing android apps with java 8
Developing android apps with java 8
Jorge Castillo Pérez
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
Abhiraj Bohra
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
艾鍗科技
 
Sentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain OntologiesSentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain Ontologies
Institute of Science Tokyo
 
Assembler
AssemblerAssembler
Assembler
Mir Majid
 
Generacion de codigo ensamblado
Generacion de codigo ensambladoGeneracion de codigo ensamblado
Generacion de codigo ensamblado
tre_na_gil
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lv
Anton Arhipov
 
Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015
Raimon Ràfols
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
Linaro
 
Java 14 features
Java 14 featuresJava 14 features
Java 14 features
Aditi Anand
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
VandanaPagar1
 
The bytecode gobbledygook
The bytecode gobbledygookThe bytecode gobbledygook
The bytecode gobbledygook
Raimon Ràfols
 
HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4HKG15-211: Advanced Toolchain Usage Part 4
HKG15-211: Advanced Toolchain Usage Part 4
Linaro
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
Erhan Bagdemir
 
Introduction to Erlang Part 1
Introduction to Erlang Part 1Introduction to Erlang Part 1
Introduction to Erlang Part 1
Dmitry Zinoviev
 
Introduction to Erlang Part 2
Introduction to Erlang Part 2Introduction to Erlang Part 2
Introduction to Erlang Part 2
Dmitry Zinoviev
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
艾鍗科技
 
Sentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain OntologiesSentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain Ontologies
Institute of Science Tokyo
 
Generacion de codigo ensamblado
Generacion de codigo ensambladoGeneracion de codigo ensamblado
Generacion de codigo ensamblado
tre_na_gil
 

Viewers also liked (20)

Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
yohanbeschi
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM Bytecode
Joe Kutner
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014
Ivan Krylov
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Carol McDonald
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentals
denis Udod
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
Anton Arhipov
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
Anton Arhipov
 
Perfect Patch
Perfect PatchPerfect Patch
Perfect Patch
Regine Deleu
 
Third Generation Internet Applications
Third Generation Internet ApplicationsThird Generation Internet Applications
Third Generation Internet Applications
Patrick Koning
 
Hands on presentatie
Hands on presentatieHands on presentatie
Hands on presentatie
Jan Vansteenkiste
 
AVO-Café
AVO-CaféAVO-Café
AVO-Café
Patrick Koning
 
Boekpresentatie (HAN)
Boekpresentatie (HAN)Boekpresentatie (HAN)
Boekpresentatie (HAN)
Patrick Koning
 
Garbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerGarbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika Langer
JAXLondon_Conference
 
Java Bytecodes by Example
Java Bytecodes by ExampleJava Bytecodes by Example
Java Bytecodes by Example
Ganesh Samarthyam
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
Azul Systems Inc.
 
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 PresentationGC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
Ludovic Poitou
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
Azul Systems Inc.
 
Mediawijsheid 2.0
Mediawijsheid 2.0 Mediawijsheid 2.0
Mediawijsheid 2.0
Patrick Koning
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
yohanbeschi
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM Bytecode
Joe Kutner
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014
Ivan Krylov
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Carol McDonald
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentals
denis Udod
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Anton Arhipov
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
Anton Arhipov
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
Anton Arhipov
 
Third Generation Internet Applications
Third Generation Internet ApplicationsThird Generation Internet Applications
Third Generation Internet Applications
Patrick Koning
 
Garbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerGarbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika Langer
JAXLondon_Conference
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
Azul Systems Inc.
 
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 PresentationGC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
Ludovic Poitou
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
Azul Systems Inc.
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
Ad

Similar to JVM bytecode - The secret language behind Java and Scala (20)

Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
lennartkats
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
Duoyi Wu
 
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
corehard_by
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
Duoyi Wu
 
Java, Up to Date Sources
Java, Up to Date SourcesJava, Up to Date Sources
Java, Up to Date Sources
輝 子安
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam
 
Comp102 lec 5.1
Comp102   lec 5.1Comp102   lec 5.1
Comp102 lec 5.1
Fraz Bakhsh
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
daewon jeong
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
Federico Tomassetti
 
458237.-Compiler-Design-Intermediate-code-generation.ppt
458237.-Compiler-Design-Intermediate-code-generation.ppt458237.-Compiler-Design-Intermediate-code-generation.ppt
458237.-Compiler-Design-Intermediate-code-generation.ppt
PalaniSamyB3
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
Ecommerce Solution Provider SysIQ
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
sdfgsdg36
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
zjkdg986
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
fdjfjfy4498
 
Mobile Software Engineering Crash Course - C02 Java Primer
Mobile Software Engineering Crash Course - C02 Java PrimerMobile Software Engineering Crash Course - C02 Java Primer
Mobile Software Engineering Crash Course - C02 Java Primer
Mohammad Shaker
 
SE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSSE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUS
nikshaikh786
 
Chapter 00 revision
Chapter 00 revisionChapter 00 revision
Chapter 00 revision
Nurhanna Aziz
 
Lifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeLifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java Bytecode
Alexander Shopov
 
Java if and else
Java if and elseJava if and else
Java if and else
pratik8897
 
Understanding Java byte code and the class file format
Understanding Java byte code and the class file formatUnderstanding Java byte code and the class file format
Understanding Java byte code and the class file format
Rafael Winterhalter
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
lennartkats
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
Duoyi Wu
 
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
corehard_by
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
Duoyi Wu
 
Java, Up to Date Sources
Java, Up to Date SourcesJava, Up to Date Sources
Java, Up to Date Sources
輝 子安
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
daewon jeong
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
Federico Tomassetti
 
458237.-Compiler-Design-Intermediate-code-generation.ppt
458237.-Compiler-Design-Intermediate-code-generation.ppt458237.-Compiler-Design-Intermediate-code-generation.ppt
458237.-Compiler-Design-Intermediate-code-generation.ppt
PalaniSamyB3
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
sdfgsdg36
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
zjkdg986
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
fdjfjfy4498
 
Mobile Software Engineering Crash Course - C02 Java Primer
Mobile Software Engineering Crash Course - C02 Java PrimerMobile Software Engineering Crash Course - C02 Java Primer
Mobile Software Engineering Crash Course - C02 Java Primer
Mohammad Shaker
 
SE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSSE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUS
nikshaikh786
 
Lifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeLifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java Bytecode
Alexander Shopov
 
Java if and else
Java if and elseJava if and else
Java if and else
pratik8897
 
Understanding Java byte code and the class file format
Understanding Java byte code and the class file formatUnderstanding Java byte code and the class file format
Understanding Java byte code and the class file format
Rafael Winterhalter
 
Ad

More from Takipi (7)

Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production Debugging
Takipi
 
AppDynamics VS New Relic – The Complete Guide
AppDynamics VS New Relic – The Complete GuideAppDynamics VS New Relic – The Complete Guide
AppDynamics VS New Relic – The Complete Guide
Takipi
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
Takipi
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListJava 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
Takipi
 
7 New Tools Java Developers Should Know
7 New Tools Java Developers Should Know7 New Tools Java Developers Should Know
7 New Tools Java Developers Should Know
Takipi
 
5 Coding Hacks to Reduce GC Overhead
5 Coding Hacks to Reduce GC Overhead5 Coding Hacks to Reduce GC Overhead
5 Coding Hacks to Reduce GC Overhead
Takipi
 
JVM Performance Magic Tricks
JVM Performance Magic TricksJVM Performance Magic Tricks
JVM Performance Magic Tricks
Takipi
 
Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production Debugging
Takipi
 
AppDynamics VS New Relic – The Complete Guide
AppDynamics VS New Relic – The Complete GuideAppDynamics VS New Relic – The Complete Guide
AppDynamics VS New Relic – The Complete Guide
Takipi
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
Takipi
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListJava 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
Takipi
 
7 New Tools Java Developers Should Know
7 New Tools Java Developers Should Know7 New Tools Java Developers Should Know
7 New Tools Java Developers Should Know
Takipi
 
5 Coding Hacks to Reduce GC Overhead
5 Coding Hacks to Reduce GC Overhead5 Coding Hacks to Reduce GC Overhead
5 Coding Hacks to Reduce GC Overhead
Takipi
 
JVM Performance Magic Tricks
JVM Performance Magic TricksJVM Performance Magic Tricks
JVM Performance Magic Tricks
Takipi
 

Recently uploaded (20)

Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptxFIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdfHigh Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptxFIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptxFIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptxFIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API CatalogMuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptxFIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdfHigh Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptxFIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptxFIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptxFIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API CatalogMuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 

JVM bytecode - The secret language behind Java and Scala

  • 1. JVM bytecode The secret language behind Java and Scala
  • 2. About Me Writing code for the past ~15 years. 1. Dev at IDF intl 2. Team lead, architect at IAI Space Industries 3. CEO at VisualTao 4. Director - AutoCAD Web & Mobile, GM Autodesk IL 5. CEO at Takipi
  • 3. Overview 1. What is bytecode 2. The 3 biggest differences between source code and bytecode 3. 5 things you should know about bytecode 4. Practical uses
  • 4. What is bytecode? A set of low-level instructions to be executed by the JVM. ~200 instruction types, each ~1-2 bytes in size. Some instructions are very similar to Java, some completely different.
  • 5. Bytecode is very similar to Assembly (That’s why we avoid it…) assembly - > exec file -> OS bytecode -> .class file -> JVM .cpp -> g++ -> exec file -> OS .java -> JavaC -> .class file -> JVM .scala-> ScalaC -> .class file -> JVM
  • 6. The 3 biggest differences between source and byte code
  • 7. 1. No variables Bytecode employs an Assembly-like register stack known as the locals stack to hold variables. Values of fields, functions and of binary operations (+, -, * ..) are held in a stack known as the operand stack.
  • 8. public getField() : double L0 public class LocalVars ALOAD 0: this { GETFIELD NoLocalVars.state : boolean private int intField; IFEQ L1 private double doubleField; L2 ALOAD 0: this private boolean state; GETFIELD NoLocalVars.intField : int ICONST_1 public double getField() IADD { ISTORE 1 if (state) L3 { GETSTATIC System.out : PrintStream ILOAD 1: a int a = intField + 1; INVOKEVIRTUAL PrintStream.println(int) : void return a; L4 } ILOAD 1: a else I2D { DRETURN double b = doubleField + 1; L1 return b; ALOAD 0: this } GETFIELD NoLocalVars.doubleField : double } DCONST_1 } DADD DSTORE 1 L5 GETSTATIC System.out : PrintStream DLOAD 1: b Notes INVOKEVIRTUAL PrintStream.println(double) : void L6 Notice how the same register slot (1) is DLOAD 1: b re-used between blocks for different variables. DRETURN L7 The variable meta-data table describes the LOCALVARIABLE this NoLocalVars L0 L7 0 mappings between registers and source code LOCALVARIABLE a int L3 L1 1 variables LOCALVARIABLE b double L5 L7 1 MAXSTACK = 4 MAXLOCALS = 3
  • 9. 2. No binary logical operators No built-in support for &&, ||, ^ Compilers implement these using jump instructions.
  • 10. public and(boolean, boolean) : void public class NoLogicalOperators L0 { ILOAD 1: a public void and(boolean a, boolean b) { IFEQ L1 if (a && b) { ILOAD 2: b System.out.println("its true"); IFEQ L1 } L2 } GETSTATIC System.out : PrintStream LDC "its true" public void or(boolean a, boolean b) { INVOKEVIRTUAL PrintStream.println(String) : void if (a || b) { L1 System.out.println("its true"); RETURN L3 } } } public or(boolean, boolean) : void L0 ILOAD 1: a IFNE L1 ILOAD 2: b IFEQ L2 L1 GETSTATIC System.out : PrintStream Notes LDC "its true" INVOKEVIRTUAL PrintStream.println(String) : void Notice how both && and || operators are L2 implemented using jump instructions who evaluate RETURN the last value if the operand stack L3
  • 11. public class NoLogicalOperators public orX2(boolean, boolean, boolean, boolean) : void { L0 public void orX2(boolean a, boolean b, ILOAD 1: a boolean c, boolean d) { IFNE L1 if ((a || b) && (c || d)) ILOAD 2: b { IFEQ L2 System.out.println("its true"); L1 } ILOAD 3: c } IFNE L3 } ILOAD 4: d IFEQ L2 L3 GETSTATIC System.out : PrintStream LDC "its true" INVOKEVIRTUAL PrintStream.println(String) : void L2 RETURN L4 Notes For composite ||, && conditions compilers will generate multiple jump combinations
  • 12. 3. No loop constructs There’s no built-in support for while, for, for-each loops. Compilers implement these using jump instructions.
  • 13. public class Loops public forLoop(int) : void { L0 public void forLoop(int n) { ICONST_0 for (int i = 0; i < n; i++) { ISTORE 2 System.out.println(i); L1 } GOTO L2 } L3 } GETSTATIC System.out : PrintStream ILOAD 2: i INVOKEVIRTUAL PrintStream.println(int) : void L4 IINC 2: i 1 L2 ILOAD 2: i ILOAD 1: n IF_ICMPLT L3 L5 RETURN L6 LOCALVARIABLE this Loops L0 L6 0 LOCALVARIABLE n int L0 L6 1 LOCALVARIABLE i int L1 L5 2 Notes A for loop is implemented using a conditional jump instruction comparing i and n
  • 14. public class Loops public whileLoop(int) : void { L0 public void whileLoop(int n) ICONST_0 { ISTORE 2 int i = 0; L1 GOTO L2 while (i < n) L3 { GETSTATIC System.out : PrintStream System.out.println(i); ILOAD 2: i i++; INVOKEVIRTUAL PrintStream.println(int) : void } L4 } IINC 2: i 1 } L2 ILOAD 2: i ILOAD 1: n IF_ICMPLT L3 L5 RETURN L6 LOCALVARIABLE this Loops L0 L6 0 LOCALVARIABLE n int L0 L6 1 LOCALVARIABLE i int L1 L6 2 Notes This while loop is also implemented using a conditional jump instruction comparing i and n. The bytecode is nearly identical to the previous loop.
  • 15. public class Loops { public forEachLoop(List) : void public void forEachLoop(List<String> strings) { L0 for (String s : strings) { ALOAD 1: strings System.out.println(s); INVOKEINTERFACE List.iterator() : Iterator } ASTORE 3 } GOTO L1 } L2 ALOAD 3 INVOKEINTERFACE Iterator.next() : Object CHECKCAST String ASTORE 2 L3 GETSTATIC System.out : PrintStream ALOAD 2: s INVOKEVIRTUAL PrintStream.println(String) : void L1 ALOAD 3 INVOKEINTERFACE Iterator.hasNext() : boolean IFNE L2 L4 RETURN L5 LOCALVARIABLE this Loops L0 L5 0 LOCALVARIABLE strings List L0 L5 1 Notes // declaration: java.util.List<java.lang.String> LOCALVARIABLE s String L3 L1 2 A for-each loop is generated by the javaC compiler } by jumping against the hasNext() method. The result bytecode is unaware of the for-each construct. Also notice how register 3 is used to hold the iterator
  • 16. 5 Things you should know about bytecode that affect everyday programming
  • 17. 1. No String support Like in C, there’s no built-in support for strings, only char arrays. Compilers usually use StringBuilder to compensate. No penalty for concatenating different data types
  • 18. public class ImplicitStrings // access flags 0x1 { public toString(int, int) : String public String toString(int a, int b) L0 { NEW StringBuilder DUP String c = "Hello " + a + "World" + b; LDC "Hello " return c; INVOKESPECIAL StringBuilder.<init>(String) : void } ILOAD 1: a } INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder LDC "World" INVOKEVIRTUAL StringBuilder.append(String) : StringBuilder ILOAD 2: b INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder INVOKEVIRTUAL StringBuilder.toString() : String ASTORE 3 L1 ALOAD 3: c ARETURN L2 LOCALVARIABLE this ImplicitStrings L0 L2 0 LOCALVARIABLE a int L0 L2 1 LOCALVARIABLE b int L0 L2 2 LOCALVARIABLE c String L1 L2 3 Notes JavaC uses java.lang.StringBuilder to combine (+)strings. Different overloads of the .append() method are used to concat different data types.
  • 19. public toString1(int, int) : String public class ImplicitStrings L0 { NEW StringBuilder public String toString1(int a, int b) DUP { LDC "Hello" String c; INVOKESPECIAL StringBuilder.<init>(String) : void ILOAD 1: a INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder c = "Hello" + a; INVOKEVIRTUAL StringBuilder.toString() : String c += "World" + b; ASTORE 3 L1 return c; NEW StringBuilder } DUP } ALOAD 3: c INVOKESTATIC String.valueOf(Object) : String INVOKESPECIAL StringBuilder.<init>(String) : void LDC "World" INVOKEVIRTUAL StringBuilder.append(String) : StringBuilder ILOAD 2: b INVOKEVIRTUAL StringBuilder.append(int) : StringBuilder INVOKEVIRTUAL StringBuilder.toString() : String ASTORE 3: c L2 ALOAD 3: c ARETURN L3 Notes While this code is identical to the previous example in terms of functionality, there’s a performance penalty to note as 2 StringBuilders are constructed
  • 20. 2. Only 4 primitive types Bytecode only operates on 4 primitives types ( int, float, double, long) vs. the 8 Java primitives. Doesn’t operate on char, bool, byte, short (treated as ints)
  • 21. public mulByeShort(byte, short) : void public class BytecodePrimitives L0 { GETSTATIC System.out : PrintStream public void mulByeShort(byte b, short c) ILOAD 1: b { ILOAD 2: c System.out.println(b * c); IMUL } INVOKEVIRTUAL PrintStream.println(int) : void L1 public void mulInts(int b, int c) RETURN { L2 LOCALVARIABLE this B_BytecodePrimitives L0 L2 0 System.out.println(b * c); LOCALVARIABLE b byte L0 L2 1 } LOCALVARIABLE c short L0 L2 2 } public mulInts(int, int) : void L0 GETSTATIC System.out : PrintStream ILOAD 1: b ILOAD 2: c IMUL INVOKEVIRTUAL PrintStream.println(int) : void L1 RETURN L2 LOCALVARIABLE this B_BytecodePrimitives L0 L2 0 LOCALVARIABLE b int L0 L2 1 LOCALVARIABLE c int L0 L2 2 Notes Notice how the bytecode for these 2 methods is identical, regardless of the difference in var types
  • 22. public class BytecodePrimitives public printIfTrue(boolean) : void { L0 public void printIfTrue(boolean b) ILOAD 1: b { IFEQ L1 L2 if (b) GETSTATIC System.out : PrintStream { LDC "Hi" System.out.println("Hi"); INVOKEVIRTUAL PrintStream.println(String) : void } L1 } RETURN L3 public void printIfN0(int i) LOCALVARIABLE this B_BytecodePrimitives L0 L3 0 { LOCALVARIABLE b boolean L0 L3 1 if (i != 0) { public printIfN0(int) : void System.out.println("Hi"); L0 ILOAD 1: i } IFEQ L1 } L2 } GETSTATIC System.out : PrintStream LDC "Hi" INVOKEVIRTUAL PrintStream.println(String) : void L1 RETURN L3 LOCALVARIABLE this B_BytecodePrimitives L0 L3 0 Notes LOCALVARIABLE i int L0 L3 1 The same observation is also true when evaluating conditions. See how both boolean and int operations are treated the same.
  • 23. 3. Using nested classes? Compilers will add synthetic $this fields. If you’re not making calls to your outer-class - don’t forget to add a static modifier.
  • 24. public class C_NestedClasses public class NestedClasses { { public class C_NestedClasses$NestedClass public class NestedClass { { final C_NestedClasses this$0 } public <init>(C_NestedClasses) : void public static class StaticNestedClass L0 { ALOAD 0: this ALOAD 1 } PUTFIELD C_NestedClasses$NestedClass.this$0 : C_NestedClasses ALOAD 0: this } INVOKESPECIAL Object.<init>() : void RETURN L1 LOCALVARIABLE this C_NestedClasses$NestedClass L0 L1 0 } public class C_NestedClasses$StaticNestedClass { public <init>() : void L0 ALOAD 0: this INVOKESPECIAL Object.<init>() : void Notes RETURN L1 The NestedClass inner-class has an implicit $this0 created for him, and assigned in the constructor. }
  • 25. Using nested classes (2)? Try and avoid implicitly creating bridge methods by invoking private members (use protected)
  • 26. static access$0(D_BridgeMethods) : int public class BridgeMethods L0 { ALOAD 0 private int member; GETFIELD D_BridgeMethods.member : int IRETURN public class BridgeMethodClass MAXSTACK = 1 { MAXLOCALS = 1 public void printBridge() { public printBridge() : void System.out.println(member); L0 } GETSTATIC System.out : PrintStream } ALOAD 0: this GETFIELD D_BridgeMethods$BridgeMethodClass.this$0 : D_BridgeMethods } INVOKESTATIC D_BridgeMethods.access$0(D_BridgeMethods) : int INVOKEVIRTUAL PrintStream.println(int) : void L1 RETURN L2 LOCALVARIABLE this D_BridgeMethods$BridgeMethodClass L0 L2 0 Notes When a private field or method is invoked javaC will add synthetic bridge methods to allow the internal class to access private members of its outer-class
  • 27. 4. Boxing and unboxing Boxing is added by the Java/Scala compiler. There’s no such concept in bytecode or in the JVM. Watch out for NullPointerExceptions
  • 28. public printSqr(int) : void L0 ILOAD 1: a ISTORE 2 public class Boxing L1 { ILOAD 1: a public void printSqr(int a) INVOKESTATIC Integer.valueOf(int) : Integer { ASTORE 3 int a1 = a; L2 GETSTATIC System.out : PrintStream Integer a2 = a; ILOAD 2: a1 ALOAD 3: a2 System.out.println(a1 * a2); INVOKEVIRTUAL Integer.intValue() : int } IMUL INVOKEVIRTUAL PrintStream.println(int) : void L3 public void check(Integer i) RETURN { L4 if (i == 0) LOCALVARIABLE this E_Boxing L0 L4 0 { LOCALVARIABLE a int L0 L4 1 System.out.println("zero"); LOCALVARIABLE a1 int L1 L4 2 } LOCALVARIABLE a2 Integer L2 L4 3 } } public check(Integer) : void L0 ALOAD 1: i INVOKEVIRTUAL Integer.intValue() : int IFNE L1 L2 Notes GETSTATIC System.out : PrintStream LDC "zero" Notice how javaC implicitly invokes the various INVOKEVIRTUAL PrintStream.println(String) : void java.lang.Integer methods. L1 RETURN Other compilers, such as scalaC, use their own L3 LOCALVARIABLE this E_Boxing L0 L3 0 boxed types LOCALVARIABLE i Integer L0 L3 1 }
  • 29. 5. 3 bytecode myths 1. Bytecode supports multiple inheritance 2. Illegal bytecode can crash the JVM (it’s blocked by the JVM verifier) 3. Low-level bytecode can operate outside the JVM sandbox
  • 30. 3 Main bytecode uses 1. Building a compiler 2. Static analysis 3. JVM bytecode instrumentation
  • 31. Building a “better Java” through Scala and ScalaC. A new OO/functional language which compiles into standard JVM bytecode. Transparent from the JVM’s perspective.
  • 32. Takipi - Overview Explain the cause of server exceptions, latency and unexpected code behavior at scale. Help R&D teams solve errors and downtime in production systems, without having to re-deploy code or sift through log files.
  • 33. Takipi & bytecode 1. Index bytecode in the cloud. 2. When an exception occurs, query the DB to understand which variables, fields and conditions are causing it. 3. Instrument new bytecode to log the values causing the exception. 4. Present a “story” of the exception to the developer.
  • 34. Thanks! Join our private beta - takipi.com/signup [email protected] @takipid (tweeting about Java, Scala, DevOps and Cloud)