SlideShare une entreprise Scribd logo
1  sur  34
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)

Contenu connexe

Tendances

Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvAnton Arhipov
 
Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Raimon 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 3Linaro
 
Java 14 features
Java 14 featuresJava 14 features
Java 14 featuresAditi Anand
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modellingVandanaPagar1
 
The bytecode gobbledygook
The bytecode gobbledygookThe bytecode gobbledygook
The bytecode gobbledygookRaimon 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 4Linaro
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in JavaErhan Bagdemir
 
Introduction to Erlang Part 1
Introduction to Erlang Part 1Introduction to Erlang Part 1
Introduction to Erlang Part 1Dmitry Zinoviev
 
Introduction to Erlang Part 2
Introduction to Erlang Part 2Introduction to Erlang Part 2
Introduction to Erlang Part 2Dmitry 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 OntologiesShinpei Hayashi
 
Generacion de codigo ensamblado
Generacion de codigo ensambladoGeneracion de codigo ensamblado
Generacion de codigo ensambladotre_na_gil
 

Tendances (20)

Ec1201
Ec1201Ec1201
Ec1201
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lv
 
Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015
 
Assembler
AssemblerAssembler
Assembler
 
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
 
Java 14 features
Java 14 featuresJava 14 features
Java 14 features
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
 
The bytecode gobbledygook
The bytecode gobbledygookThe bytecode gobbledygook
The bytecode gobbledygook
 
Alp 05
Alp 05Alp 05
Alp 05
 
Assembler (2)
Assembler (2)Assembler (2)
Assembler (2)
 
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
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
 
Introduction to Erlang Part 1
Introduction to Erlang Part 1Introduction to Erlang Part 1
Introduction to Erlang Part 1
 
Introduction to Erlang Part 2
Introduction to Erlang Part 2Introduction to Erlang Part 2
Introduction to Erlang Part 2
 
Developing android apps with java 8
Developing android apps with java 8Developing android apps with java 8
Developing android apps with java 8
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
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
 
Assembler
AssemblerAssembler
Assembler
 
Generacion de codigo ensamblado
Generacion de codigo ensambladoGeneracion de codigo ensamblado
Generacion de codigo ensamblado
 

En vedette

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 - 20130924yohanbeschi
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM BytecodeJoe Kutner
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014Ivan 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, TuningCarol McDonald
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentalsdenis Udod
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton 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 2012Anton 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 2011Anton Arhipov
 
Third Generation Internet Applications
Third Generation Internet ApplicationsThird Generation Internet Applications
Third Generation Internet ApplicationsPatrick Koning
 
Garbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerGarbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerJAXLondon_Conference
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage CollectionAzul 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 PresentationLudovic 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 ItAzul Systems Inc.
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 

En vedette (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
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM Bytecode
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014
 
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
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentals
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
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
 
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
 
Perfect Patch
Perfect PatchPerfect Patch
Perfect Patch
 
Third Generation Internet Applications
Third Generation Internet ApplicationsThird Generation Internet Applications
Third Generation Internet Applications
 
Hands on presentatie
Hands on presentatieHands on presentatie
Hands on presentatie
 
AVO-Café
AVO-CaféAVO-Café
AVO-Café
 
Boekpresentatie (HAN)
Boekpresentatie (HAN)Boekpresentatie (HAN)
Boekpresentatie (HAN)
 
Garbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerGarbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika Langer
 
Java Bytecodes by Example
Java Bytecodes by ExampleJava Bytecodes by Example
Java Bytecodes by Example
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
 
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
 
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
 
Mediawijsheid 2.0
Mediawijsheid 2.0 Mediawijsheid 2.0
Mediawijsheid 2.0
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 

Similaire à JVM bytecode - The secret language behind Java and Scala

Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)changehee lee
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engineDuoyi Wu
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javacAnna Brzezińska
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...André Oriani
 
Londiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQLLondiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQLelliando dias
 
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 formatRafael Winterhalter
 
OPERATING OVERLOADING IN VHDL
OPERATING OVERLOADING IN VHDLOPERATING OVERLOADING IN VHDL
OPERATING OVERLOADING IN VHDLBLESSYDAISE PAUL
 
Droidcon Poland - From Kotlin to Machine Code
Droidcon Poland - From Kotlin to Machine CodeDroidcon Poland - From Kotlin to Machine Code
Droidcon Poland - From Kotlin to Machine CodeTomasz Polanski
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗Pofat Tseng
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationWei-Ren Chen
 
Glow user review
Glow user reviewGlow user review
Glow user review冠旭 陳
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And AnswerJagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answerlavparmar007
 
Understanding the Common Intermediate Language (CIL)
Understanding the Common Intermediate Language (CIL)Understanding the Common Intermediate Language (CIL)
Understanding the Common Intermediate Language (CIL)James Crowley
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
Syntactic Salt and Sugar Presentation
Syntactic Salt and Sugar PresentationSyntactic Salt and Sugar Presentation
Syntactic Salt and Sugar Presentationgrepalex
 
jimmy hacking (at) Microsoft
jimmy hacking (at) Microsoftjimmy hacking (at) Microsoft
jimmy hacking (at) MicrosoftJimmy Schementi
 

Similaire à JVM bytecode - The secret language behind Java and Scala (20)

Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...
 
Londiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQLLondiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQL
 
F#3.0
F#3.0 F#3.0
F#3.0
 
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
 
OPERATING OVERLOADING IN VHDL
OPERATING OVERLOADING IN VHDLOPERATING OVERLOADING IN VHDL
OPERATING OVERLOADING IN VHDL
 
Droidcon Poland - From Kotlin to Machine Code
Droidcon Poland - From Kotlin to Machine CodeDroidcon Poland - From Kotlin to Machine Code
Droidcon Poland - From Kotlin to Machine Code
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗
 
Codejunk Ignitesd
Codejunk IgnitesdCodejunk Ignitesd
Codejunk Ignitesd
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
 
Glow user review
Glow user reviewGlow user review
Glow user review
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
Understanding the Common Intermediate Language (CIL)
Understanding the Common Intermediate Language (CIL)Understanding the Common Intermediate Language (CIL)
Understanding the Common Intermediate Language (CIL)
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Syntactic Salt and Sugar Presentation
Syntactic Salt and Sugar PresentationSyntactic Salt and Sugar Presentation
Syntactic Salt and Sugar Presentation
 
jimmy hacking (at) Microsoft
jimmy hacking (at) Microsoftjimmy hacking (at) Microsoft
jimmy hacking (at) Microsoft
 

Plus de Takipi

Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production DebuggingTakipi
 
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 GuideTakipi
 
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 8Takipi
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListJava 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListTakipi
 
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 KnowTakipi
 
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 OverheadTakipi
 
JVM Performance Magic Tricks
JVM Performance Magic TricksJVM Performance Magic Tricks
JVM Performance Magic TricksTakipi
 

Plus de Takipi (7)

Advanced Production Debugging
Advanced Production DebuggingAdvanced Production Debugging
Advanced Production Debugging
 
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
 
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
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListJava 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
 
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
 
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
 
JVM Performance Magic Tricks
JVM Performance Magic TricksJVM Performance Magic Tricks
JVM Performance Magic Tricks
 

Dernier

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Dernier (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

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 tal.weiss@takipi.com @takipid (tweeting about Java, Scala, DevOps and Cloud)