SlideShare ist ein Scribd-Unternehmen logo
1 von 102
Introduction to Class File
Format & Byte Code
By Douglas Q Hawkins

                     Wireless
                 Event Code: JM67
Topics
 Class File Format
 Byte Code
 Dynamic Generation of Byte Code
 Annotation Processing Tool
Class File Format
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE      Minor Version Major Version


                Constant Pool




                                               d
                                           ize
                                          gs

                                        on
                                       ar

                                     hr
                                    ar
                                  nc
                       su atile t/v




                       pu te d
  Flags    This Class Super Class




                           al sy
                       ce




                          iva te
                           tiv ct

                           l n
                       ab tfp


                       vo nsie




                       pr ec
                       fin r/
                       na ra
                    fa




                              ic
                       tra e




                       pr ic
                           pe
                   Interfaces


                           st
                  er




                           bl
                          ric




                          ot
                          at
                 int

                       st




                       st
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Class File Format
 CA   FE   BA    BE    Minor Version Major Version


                Constant Pool


  Flags    This Class Super Class
                   Interfaces
                   Fields

                  Methods
                  Attributes
Constant Pool
C        2   UTF   10                  HelloWorld
                                           C  4            UTF    16
                        “java/lang/Object”

UTF      6                         “<init>”                        UTF

    3             “()V”            UTF    4            “Code”
              M     3        9     N&T    5        6       UTF    4
             “main”                UTF   22
                      “([Ljava/lang/String;)V”

                               F     13       15       C     14    UTF

    16                     “java/lang/System”
Constant Pool (continued)
                      N&T    16     17 UTF        3        “out”
          UTF     21                “Ljava/io/PrintStream;”

                                                                           S

    19    UTF     11                     “Hello World”
                                                        M21           23
C        22     UTF     19             “java/io/PrintStream”

                                                  N&T       24   25    UTF

    7                                 “println”
UTF      21                       (Ljava/lang/String;)V
Field Format
  Flags   Name       Descriptor
              Attributes
Name       Flags
                        Field Format



int
     er
          fa
             ce
st
   ric
    Attributes




ab tfp
    s
na tra
    tiv ct
tra e
vo nsie
           Descriptor




    l n
su atile t/v
    pe      ar
fin r/          ar
    al sy         gs
st         nc
   at         hr
pr ic           on
   ot              ize
pr ec
   iva te              d
pu te d
    bl
       ic
Field Format
  Flags   Name        Descriptor
                   “name”
              Attributes
Field Format
  Flags   Name       Descriptor   “Ljava/lang/String;”
              Attributes
Field Format
  Flags   Name       Descriptor
              Attributes
Field Format
  Flags   Name       Descriptor
              Attributes

            ConstantValue
Method Format
 Flags   Name       Descriptor
             Attributes
Name       Flags




int
     er
          fa
             ce
                        Method Format




st
   ric
    Attributes




ab tfp
    s
na tra
    tiv ct
tra e
vo nsie
           Descriptor




    l n
su atile t/v
    pe      ar
fin r/          ar
    al sy         gs
st         nc
   at         hr
pr ic           on
   ot              ize
pr ec
   iva te              d
pu te d
    bl
       ic
Method Format
 Flags   Name        Descriptor
                   “main”
             Attributes
Method Format
 Flags   Name       Descriptor   “([Ljava/lang/String;)V”
             Attributes
Method Format
 Flags   Name       Descriptor
             Attributes
Method Format
 Flags   Name       Descriptor
             Attributes

             Exceptions
Method Format
 Flags   Name       Descriptor
             Attributes

             Exceptions


               Code
Constant Pool
C        2   UTF   10                  HelloWorld
                                           C  4            UTF    16
                        “java/lang/Object”

UTF      6                         “<init>”                        UTF

    3             “()V”            UTF    4            “Code”
              M     3        9     N&T    5        6       UTF    4
             “main”                UTF   22
                      “([Ljava/lang/String;)V”

                               F     13       15       C     14    UTF

    16                     “java/lang/System”
Constant Pool
1                2
    C        2       UTF   10                  HelloWorld
                                                3                    4
                                                   C  4                  UTF    16
                                “java/lang/Object”

5                                                                               6
    UTF      6                              “<init>”                                UTF
                                            7
        3               “()V”             UTF   4                “Code”
                 8                      9                            10
                    M     3        9      N&T   5           6            UTF    4
                                       11
                   “main”                 UTF  22
                            “([Ljava/lang/String;)V”

                                   12                       13                  14
                                        F       13     15        C         14       UTF

        16                         “java/lang/System”
Constant Pool
1                2
    C        2       UTF   10                  HelloWorld
                                                3                    4
                                                   C  4                  UTF    16
                                “java/lang/Object”

5                                                                               6
    UTF      6                              “<init>”                                UTF
                                            7
        3               “()V”             UTF   4                “Code”
                 8                      9                            10
                    M     3        9      N&T   5           6            UTF    4
                                       11
                   “main”                 UTF  22
                            “([Ljava/lang/String;)V”

                                   12                       13                  14
                                        F       13     15        C         14       UTF

        16                         “java/lang/System”
Constant Pool
1                2
    C        2       UTF   10                  HelloWorld
                                                3                    4
                                                   C  4                  UTF    16
                                “java/lang/Object”

5                                                                               6
    UTF      6                              “<init>”                                UTF
                                            7
        3               “()V”             UTF   4                “Code”
                 8                      9                            10
                    M     3        9      N&T   5           6            UTF    4
                                       11
                   “main”                 UTF  22
                            “([Ljava/lang/String;)V”

                                   12                       13                  14
                                        F       13     15        C         14       UTF

        16                         “java/lang/System”
Browsing Class File Format




       JClassLib Viewer
Byte Code
Stack Based Virtual Machine
0 iconst_1
              0   1   2   3
1 iconst_2
2 iadd
3 istore_0
4 iload_0
Stack Based Virtual Machine
0 iconst_1
                 0   1   2   3
1 iconst_2
2 iadd
3 istore_0
4 iload_0




             1
Stack Based Virtual Machine
0 iconst_1
                 0   1   2   3
1 iconst_2
2 iadd
3 istore_0
4 iload_0




             2
             1
Stack Based Virtual Machine
0 iconst_1
                   0   1   2   3
1 iconst_2
2 iadd
3 istore_0
4 iload_0




             1+2
Stack Based Virtual Machine
0 iconst_1
                 0   1   2   3
1 iconst_2
2 iadd
3 istore_0
4 iload_0




             3
Stack Based Virtual Machine
0 iconst_1
              0       1   2   3
1 iconst_2        3
2 iadd
3 istore_0
4 iload_0
Stack Based Virtual Machine
0 iconst_1
                 0       1   2   3
1 iconst_2           3
2 iadd
3 istore_0
4 iload_0




             3
Operation Types
 Load and Store
 Arithmetic and Logic
 Type Conversion
 Branch Instructions
 Object Creation and Manipulation
 Operand Stack
 Method Invocation
Data Types




                                   ac ts refix

                                          als
                                    ns e P

                                   ray oc
                                 Co Cod
                                 By ture



                                 Ar k / L
                                 St tan
                                    na
                                   te
                                Sig
                    boolean     Z
    Integer Types

                    byte        B b
                    char        C c
                    short       S s
                    int         I i
                    long        J l
                    float        F f
                    double      D d
                    reference   L a
                    void        V
Parameters and Local Variables
static int volume(
  int width,
  int depth,
  int height )
{
  int area = width * depth;
  int volume = area * height;
  return volume;
}
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
  int height )                   2 imul
{                                3 istore_3
  int area = width * depth;
                                 4 iload_3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                             e
  int height )




                                                      are t
                                                            h



                                                        lum
                                                         igh
                                                           h
                                                         pt


                                                          a
                                                        dt
{                                3 istore_3




                                                      de
                                                      he


                                                      vo
                                                      wi
                                                  0    1   2   3   4
  int area = width * depth;
                                 4 iload_3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                             e
  int height )




                                                      are t
                                                            h



                                                        lum
                                                         igh
                                                           h
                                                         pt


                                                          a
                                                        dt
{                                3 istore_3




                                                      de
                                                      he


                                                      vo
                                                      wi
                                                  0       1       2       3   4
  int area = width * depth;
                                 4 iload_3            1       2       3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3   4
  int area = width * depth;
                                 4 iload_3                1       2       3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn         1
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3   4
  int area = width * depth;
                                 4 iload_3                1       2       3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4   2
                                11ireturn         1
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3   4
  int area = width * depth;
                                 4 iload_3                1       2       3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn         2
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                             e
  int height )




                                                      are t
                                                            h



                                                        lum
                                                         igh
                                                           h
                                                         pt


                                                          a
                                                        dt
{                                3 istore_3




                                                      de
                                                      he


                                                      vo
                                                      wi
                                                  0       1       2       3       4
  int area = width * depth;
                                 4 iload_3            1       2       3       2
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3       4
  int area = width * depth;
                                 4 iload_3                1       2       3       2
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn         2
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3       4
  int area = width * depth;
                                 4 iload_3                1       2       3       2
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4   3
                                11ireturn         2
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3       4
  int area = width * depth;
                                 4 iload_3                1       2       3       2
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn         6
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                             e
  int height )




                                                      are t
                                                            h



                                                        lum
                                                         igh
                                                           h
                                                         pt


                                                          a
                                                        dt
{                                3 istore_3




                                                      de
                                                      he


                                                      vo
                                                      wi
                                                  0       1       2       3       4
  int area = width * depth;
                                 4 iload_3            1       2       3       2       6
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                                 e
  int height )




                                                          are t
                                                                h



                                                            lum
                                                             igh
                                                               h
                                                             pt


                                                              a
                                                            dt
{                                3 istore_3




                                                          de
                                                          he


                                                          vo
                                                          wi
                                                      0       1       2       3       4
  int area = width * depth;
                                 4 iload_3                1       2       3       2       6
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn         6
Parameters and Local Variables
static int volume(               0 iload_0
  int width,
                                 1 iload_1
  int depth,
                                 2 imul




                                                             e
  int height )




                                                      are t
                                                            h



                                                        lum
                                                         igh
                                                           h
                                                         pt


                                                          a
                                                        dt
{                                3 istore_3




                                                      de
                                                      he


                                                      vo
                                                      wi
                                                  0       1       2       3       4
  int area = width * depth;
                                 4 iload_3            1       2       3       2       6
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11ireturn
Static vs Virtual Methods
static int volume(               0 iload_0
  int width,                     1 iload_1
  int depth,
                                 2 imul




                                                              e
  int height )




                                                      are t
                                                      he h


                                                        lum
                                                            h

                                                         igh
                                                         pt


                                                          a
                                                         dt
{                                3 istore_3




                                                      de
                                                  wi




                                                      vo
                                                  0   1   2   3   4   5
  int area = width * depth;      4 iload_3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11 ireturn
Static vs Virtual Methods
int volume(                      0 iload_0
  int width,                     1 iload_1
  int depth,
                                 2 imul




                                                              e
  int height )




                                                      are t
                                                      he h


                                                        lum
                                                            h

                                                         igh
                                                         pt


                                                          a
                                                         dt
{                                3 istore_3




                                                      de
                                                  wi




                                                      vo
                                                  0   1   2   3   4   5
  int area = width * depth;      4 iload_3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11 ireturn
Static vs Virtual Methods
int volume(                      0 iload_0
  int width,                     1 iload_1
  int depth,
                                 2 imul




                                                          e
  int height )




                                                  are t
                                                  he h


                                                    lum
                                                        h

                                                     igh
                                                      pt


                                                       a
                                                     dt
                                                      s
{                                3 istore_3




                                                  de
                                                  thi
                                                  wi




                                                  vo
                                                  0   1   2   3   4   5
  int area = width * depth;      4 iload_3
  int volume = area * height;
  return volume;                 5 iload_2
}                                6 imul
                                 7 istore     4
                                 9 iload      4
                                11 ireturn
Static vs Virtual Methods
int volume(                      0 iload_1
  int width,                     1 iload_2
  int depth,
                                 2 imul




                                                         e
  int height )




                                                 are t
                                                 he h


                                                   lum
                                                       h

                                                    igh
                                                     pt


                                                      a
                                                    dt
                                                     s
{                                3 istore    4




                                                 de
                                                 thi
                                                 wi




                                                 vo
                                                 0   1   2   3   4   5
  int area = width * depth;      5 iload     4
  int volume = area * height;
  return volume;                 7 iload_3
}                                8 imul
                                 9 istore    5
                                11 iload     5
                                13 ireturn
Hello World
System.out.println( “Hello World” );
Hello World
System.out.println( “Hello World” );

 0   getstatic     System.out

 3   ldc           “Hello World”

 5   invokevirtual PrintStream.println

 8   return
Hello World
System.out.println( “Hello World” );
                                         0   1       2   3
 0   getstatic     System.out

 3   ldc           “Hello World”

 5   invokevirtual PrintStream.println
                                             “Hello World”
 8   return



                                                 System.out
Hello World
System.out.println( “Hello World” );
                                         0   1       2   3
 0   getstatic     System.out

 3   ldc           “Hello World”

 5   invokevirtual PrintStream.println
                                             “Hello World”
 8   return



                                                 System.out
Hello World
System.out.println( “Hello World” );
                                         0   1       2   3
 0   getstatic     System.out

 3   ldc           “Hello World”

 5   invokevirtual PrintStream.println
                                             “Hello World”
 8   return



                                                 System.out
Hello World




                                                      g
                                                s
                                                    ms
                                             thi
System.out.println( “Hello World” );
                                         0      1         2   3
 0   getstatic     System.out

 3   ldc           “Hello World”

 5   invokevirtual PrintStream.println
                                                    “Hello World”
 8   return



                                                    System.out
Types of Method Invocations
 invokestatic - invoke static methods
 invokevirtual - invoke instance method from class
 invokeinterface - invoke instance method from interface
 invokespecial - invoke <init> / invoke super method
New Object
 return new BigDecimal(“2.0”);
New Object
    return new BigDecimal(“2.0”);

0    new             BigDecimal

3    dup

4    ldc             “2.0”

6    invokespecial     BigDecimal.<init>

9    areturn
New Object
    return new BigDecimal(“2.0”);
                                           0   1    2      3
0    new             BigDecimal

3    dup

4    ldc             “2.0”
                                                   “2.0”
6    invokespecial     BigDecimal.<init>

9    areturn
New Object
    return new BigDecimal(“2.0”);
                                           0   1       2     3
0    new             BigDecimal

3    dup

4    ldc             “2.0”
                                                     “2.0”
6    invokespecial     BigDecimal.<init>

9    areturn

                                                   BigDecimal
New Object
    return new BigDecimal(“2.0”);
                                           0   1       2     3
0    new             BigDecimal

3    dup

4    ldc             “2.0”
                                                     “2.0”
6    invokespecial     BigDecimal.<init>

9    areturn

                                                   BigDecimal
New Object
    return new BigDecimal(“2.0”);
                                           0   1       2     3
0    new             BigDecimal

3    dup

4    ldc             “2.0”
                                                     “2.0”
6    invokespecial     BigDecimal.<init>

9    areturn

                                                   BigDecimal
New Object
    return new BigDecimal(“2.0”);
                                           0   1       2     3
0    new             BigDecimal

3    dup

4    ldc             “2.0”
                                                     “2.0”
6    invokespecial     BigDecimal.<init>

9    areturn

                                                   BigDecimal
If / Else
static boolean isPositive( int val ){
  if ( val > 0 ) {
    return true;
  } else {
    return false;
  }
}
If / Else
static boolean isPositive( int val ){          0 iload_0




                                        test
  if ( val > 0 ) {                             1 ifle        +5 //6
    return true;
                                               4 iconst_1
  } else {




                                        if
    return false;                              5 ireturn
  }                                            6 iconst_0




                                        else
}                                              7 ireturn
If / Else
static boolean isPositive( int val ){          0 iload_0




                                        test
  if ( val > 0 ) {                             1 ifle        +5 //6
    return true;
                                               4 iconst_1
  } else {




                                        if
    return false;                              5 ireturn
  }                                            6 iconst_0




                                        else
}                                              7 ireturn
If / Else
static boolean isPositive( int val ){          0 iload_0




                                        test
  if ( val > 0 ) {                             1 ifle        +5 //6
    return true;
                                               4 iconst_1
  } else {




                                        if
    return false;                              5 ireturn
  }                                            6 iconst_0




                                        else
}                                              7 ireturn
If / Else
static boolean isPositive( int val ){          0 iload_0




                                        test
  if ( val > 0 ) {                             1 ifle        +5 //6
    return true;
                                               4 iconst_1
  } else {




                                        if
    return false;                              5 ireturn
  }                                            6 iconst_0




                                        else
}                                              7 ireturn
If / Else
static boolean isPositive( int val ){          0 iload_0




                                        test
  if ( val > 0 ) {                             1 ifle        +5 //6
    return true;
                                               4 iconst_1
  } else {




                                        if
    return false;                              5 ireturn
  }                                            6 iconst_0




                                        else
}                                              7 ireturn

static boolean isPositive( int val ){
  return ( val > 0 );
}
If / Else
static boolean isPositive( int val ){
  if ( val > 0 ) {
    return true;
  } else {
    return false;
  }
}
static boolean isPositive( int val ){
  return ( val > 0 );
}
If / Else
static boolean isPositive( int val ){          0 iload_0




                                        test
  if ( val > 0 ) {                             1 ifle        +5 //6
    return true;
                                               4 iconst_1
  } else {




                                        if
    return false;                              5 ireturn
  }                                            6 iconst_0




                                        else
}                                              7 ireturn

static boolean isPositive( int val ){
  return ( val > 0 );
}
For Loop
static int sum( int min, int max ){
  int sum = 0;
  for ( int i=min; i<max; ++i ){
    sum += i;
  }
  return sum;
}
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
before
                                                            0 iconst_0
   For Loop




                                      init & test loop
                                                            1 istore_2
                                                            2 iload_1
static int sum( int min, int max ){                         3 istore_3
  int sum = 0;                                              4 goto        +10 //14
  for ( int i=min; i<max; ++i ){                            7 iload_2




                                            loop body
    sum += i;                                               8 iload_3
  }                                                         9 iadd
  return sum;                                              10 istore_2
}


                                            inc
                                                           11 iinc        3 by 1
                                                           14 iload_3
                                            test           15 iload_1
                                                           16 if_icmplt   -9 //7
                                                           19 iload_2
                                      after
                                      loop



                                                           20 ireturn
Exception Handling
static int read( InputStream in ) {
  try {
    return in.read();
  } catch ( IOException e ) {
    return -1;
  } finally {
    IoUtils.closeQuietly( in );
  }
}
0 aload_0
Exception Handling                                      1 invokevirtual InputStream.read




                                      try / finally
static int read( InputStream in ) {                     4 istore_1
  try {                                                 5 aload_0
    return in.read();                                   6 invokestatic IoUtils.closeQuietly
  } catch ( IOException e ) {                           9 iload_1
    return -1;                                         10 ireturn
  } finally {
                                                       11 pop
    IoUtils.closeQuietly( in );



                                      catch / finally
                                                       12 aload_0
  }
                                                       13 invokestatic IoUtils.closeQuietly
}
                                                       16 iconst_m1
                                                       17 ireturn
                                                       18 astore_2
                                                       19 aload_0
                                      finally



                                                       20 invokestatic IoUtils.closeQuietly
                                                       23 aload_2
                                                       24 athrow
0 aload_0
Exception Handling                                      1 invokevirtual InputStream.read




                                      try / finally
static int read( InputStream in ) {                     4 istore_1
  try {                                                 5 aload_0
    return in.read();                                   6 invokestatic IoUtils.closeQuietly
  } catch ( IOException e ) {                           9 iload_1
    return -1;                                         10 ireturn
  } finally {
                                                       11 pop
    IoUtils.closeQuietly( in );



                                      catch / finally
                                                       12 aload_0
  }
                                                       13 invokestatic IoUtils.closeQuietly
}
                                                       16 iconst_m1
                                                       17 ireturn
                                                       18 astore_2
                                                       19 aload_0
                                      finally



                                                       20 invokestatic IoUtils.closeQuietly
                                                       23 aload_2
                                                       24 athrow
0 aload_0
Exception Handling                                       1 invokevirtual InputStream.read




                                       try / finally
static int read( InputStream in ) {                      4 istore_1
  try {                                                  5 aload_0
    return in.read();                                    6 invokestatic IoUtils.closeQuietly
  } catch ( IOException e ) {                            9 iload_1
    return -1;                                          10 ireturn
  } finally {
                                                        11 pop
    IoUtils.closeQuietly( in );



                                       catch / finally
                                                        12 aload_0
  }
                                                        13 invokestatic IoUtils.closeQuietly
}
                                                        16 iconst_m1
                                                        17 ireturn
         Exception Table
                                                        18 astore_2
start   end    handler    Exception
                                                        19 aload_0
  0      5       11      IOException
                                       finally



                                                        20 invokestatic IoUtils.closeQuietly
  0      5       18         any
                                                        23 aload_2
 11      12      18         any                         24 athrow
0 aload_0
Exception Handling                                       1 invokevirtual InputStream.read




                                       try / finally
static int read( InputStream in ) {                      4 istore_1
  try {                                                  5 aload_0
    return in.read();                                    6 invokestatic IoUtils.closeQuietly
  } catch ( IOException e ) {                            9 iload_1
    return -1;                                          10 ireturn
  } finally {
                                                        11 pop
    IoUtils.closeQuietly( in );



                                       catch / finally
                                                        12 aload_0
  }
                                                        13 invokestatic IoUtils.closeQuietly
}
                                                        16 iconst_m1
                                                        17 ireturn
         Exception Table
                                                        18 astore_2
start   end    handler    Exception
                                                        19 aload_0
  0      5       11      IOException
                                       finally



                                                        20 invokestatic IoUtils.closeQuietly
  0      5       18         any
                                                        23 aload_2
 11      12      18         any                         24 athrow
More Attributes...
 Java 1.2+
   InnerClass

   Synthetic

   Deprecated
More Attributes...
 Java 1.2+
   InnerClass

   Synthetic

   Deprecated


Debugging
  LineNumberTable

  LocalVariableTable

  SourceFile
More Attributes...
 Java 1.2+             Java 5+
   InnerClass            Signature
   Synthetic             RuntimeVisibleAnnotations
   Deprecated            RuntimeInvisibleAnnotations

Debugging
  LineNumberTable

  LocalVariableTable

  SourceFile
Byte Code Generation
Resources
The Java Virtual Machine Specification
http://java.sun.com/docs/books/jvms/
JClassLib Viewer
http://www.ej-technologies.com/products/jclasslib/
overview.html
Maxine VM
http://labs.oracle.com/projects/maxine/
New Features in Java 6 - Annotation Processing
http://www.javabeat.net/articles/14-java-60-features-
part-2-pluggable-annotation-proce-1.html

Weitere ähnliche Inhalte

Andere mochten auch

The Delivery Hero - A Simpsons As A Service Storyboard
The Delivery Hero - A Simpsons As A Service StoryboardThe Delivery Hero - A Simpsons As A Service Storyboard
The Delivery Hero - A Simpsons As A Service StoryboardChristoph Engelbert
 
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint PetersburgUnsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint PetersburgChristoph Engelbert
 
Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014Christoph Engelbert
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
A Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe WorldA Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe WorldChristoph Engelbert
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage CollectionDoug Hawkins
 
In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015Christoph Engelbert
 

Andere mochten auch (8)

The Delivery Hero - A Simpsons As A Service Storyboard
The Delivery Hero - A Simpsons As A Service StoryboardThe Delivery Hero - A Simpsons As A Service Storyboard
The Delivery Hero - A Simpsons As A Service Storyboard
 
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint PetersburgUnsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
Unsafe Java World - Crossing the Borderline - JokerConf 2014 Saint Petersburg
 
Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014Distributed computing with Hazelcast - JavaOne 2014
Distributed computing with Hazelcast - JavaOne 2014
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
A Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe WorldA Post-Apocalyptic sun.misc.Unsafe World
A Post-Apocalyptic sun.misc.Unsafe World
 
Understanding Garbage Collection
Understanding Garbage CollectionUnderstanding Garbage Collection
Understanding Garbage Collection
 
In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015In-Memory Computing - Distributed Systems - Devoxx UK 2015
In-Memory Computing - Distributed Systems - Devoxx UK 2015
 
Hazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGridHazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGrid
 

Ähnlich wie Introduction to Class File Format & Byte Code

JVM Internals by Douglas Hawkins
JVM Internals by Douglas Hawkins JVM Internals by Douglas Hawkins
JVM Internals by Douglas Hawkins zuluJDK
 
JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012Doug Hawkins
 
Overview of methods for variant calling from next-generation sequence data
Overview of methods for variant calling from next-generation sequence dataOverview of methods for variant calling from next-generation sequence data
Overview of methods for variant calling from next-generation sequence dataThomas Keane
 
A First Analysis of String APIs: the Case of Pharo
A First Analysis of String APIs: the Case of PharoA First Analysis of String APIs: the Case of Pharo
A First Analysis of String APIs: the Case of PharoESUG
 
Sparse Content Map Storage System
Sparse Content Map Storage SystemSparse Content Map Storage System
Sparse Content Map Storage Systemianeboston
 

Ähnlich wie Introduction to Class File Format & Byte Code (7)

JVM Internals by Douglas Hawkins
JVM Internals by Douglas Hawkins JVM Internals by Douglas Hawkins
JVM Internals by Douglas Hawkins
 
JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012JVM Internals - NHJUG Jan 2012
JVM Internals - NHJUG Jan 2012
 
Linked Data Integration
Linked Data IntegrationLinked Data Integration
Linked Data Integration
 
Akka JUGL 2012
Akka JUGL 2012Akka JUGL 2012
Akka JUGL 2012
 
Overview of methods for variant calling from next-generation sequence data
Overview of methods for variant calling from next-generation sequence dataOverview of methods for variant calling from next-generation sequence data
Overview of methods for variant calling from next-generation sequence data
 
A First Analysis of String APIs: the Case of Pharo
A First Analysis of String APIs: the Case of PharoA First Analysis of String APIs: the Case of Pharo
A First Analysis of String APIs: the Case of Pharo
 
Sparse Content Map Storage System
Sparse Content Map Storage SystemSparse Content Map Storage System
Sparse Content Map Storage System
 

Mehr von Doug Hawkins

JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksDoug Hawkins
 
ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"Doug Hawkins
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance PuzzlersDoug Hawkins
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in JavaDoug Hawkins
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Doug Hawkins
 
JVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime OptimizationsJVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime OptimizationsDoug Hawkins
 

Mehr von Doug Hawkins (7)

JVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's TricksJVM Mechanics: Understanding the JIT's Tricks
JVM Mechanics: Understanding the JIT's Tricks
 
ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"ReadyNow: Azul's Unconventional "AOT"
ReadyNow: Azul's Unconventional "AOT"
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
 
JVM Mechanics
JVM MechanicsJVM Mechanics
JVM Mechanics
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
 
JVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime OptimizationsJVM Internals - Garbage Collection & Runtime Optimizations
JVM Internals - Garbage Collection & Runtime Optimizations
 

Kürzlich hochgeladen

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Introduction to Class File Format & Byte Code

  • 1. Introduction to Class File Format & Byte Code By Douglas Q Hawkins Wireless Event Code: JM67
  • 2. Topics Class File Format Byte Code Dynamic Generation of Byte Code Annotation Processing Tool
  • 4. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 5. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 6. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 7. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 8. Class File Format CA FE BA BE Minor Version Major Version Constant Pool d ize gs on ar hr ar nc su atile t/v pu te d Flags This Class Super Class al sy ce iva te tiv ct l n ab tfp vo nsie pr ec fin r/ na ra fa ic tra e pr ic pe Interfaces st er bl ric ot at int st st Fields Methods Attributes
  • 9. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 10. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 11. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 12. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 13. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 14. Class File Format CA FE BA BE Minor Version Major Version Constant Pool Flags This Class Super Class Interfaces Fields Methods Attributes
  • 15. Constant Pool C 2 UTF 10 HelloWorld C 4 UTF 16 “java/lang/Object” UTF 6 “<init>” UTF 3 “()V” UTF 4 “Code” M 3 9 N&T 5 6 UTF 4 “main” UTF 22 “([Ljava/lang/String;)V” F 13 15 C 14 UTF 16 “java/lang/System”
  • 16. Constant Pool (continued) N&T 16 17 UTF 3 “out” UTF 21 “Ljava/io/PrintStream;” S 19 UTF 11 “Hello World” M21 23 C 22 UTF 19 “java/io/PrintStream” N&T 24 25 UTF 7 “println” UTF 21 (Ljava/lang/String;)V
  • 17. Field Format Flags Name Descriptor Attributes
  • 18. Name Flags Field Format int er fa ce st ric Attributes ab tfp s na tra tiv ct tra e vo nsie Descriptor l n su atile t/v pe ar fin r/ ar al sy gs st nc at hr pr ic on ot ize pr ec iva te d pu te d bl ic
  • 19. Field Format Flags Name Descriptor “name” Attributes
  • 20. Field Format Flags Name Descriptor “Ljava/lang/String;” Attributes
  • 21. Field Format Flags Name Descriptor Attributes
  • 22. Field Format Flags Name Descriptor Attributes ConstantValue
  • 23. Method Format Flags Name Descriptor Attributes
  • 24. Name Flags int er fa ce Method Format st ric Attributes ab tfp s na tra tiv ct tra e vo nsie Descriptor l n su atile t/v pe ar fin r/ ar al sy gs st nc at hr pr ic on ot ize pr ec iva te d pu te d bl ic
  • 25. Method Format Flags Name Descriptor “main” Attributes
  • 26. Method Format Flags Name Descriptor “([Ljava/lang/String;)V” Attributes
  • 27. Method Format Flags Name Descriptor Attributes
  • 28. Method Format Flags Name Descriptor Attributes Exceptions
  • 29. Method Format Flags Name Descriptor Attributes Exceptions Code
  • 30. Constant Pool C 2 UTF 10 HelloWorld C 4 UTF 16 “java/lang/Object” UTF 6 “<init>” UTF 3 “()V” UTF 4 “Code” M 3 9 N&T 5 6 UTF 4 “main” UTF 22 “([Ljava/lang/String;)V” F 13 15 C 14 UTF 16 “java/lang/System”
  • 31. Constant Pool 1 2 C 2 UTF 10 HelloWorld 3 4 C 4 UTF 16 “java/lang/Object” 5 6 UTF 6 “<init>” UTF 7 3 “()V” UTF 4 “Code” 8 9 10 M 3 9 N&T 5 6 UTF 4 11 “main” UTF 22 “([Ljava/lang/String;)V” 12 13 14 F 13 15 C 14 UTF 16 “java/lang/System”
  • 32. Constant Pool 1 2 C 2 UTF 10 HelloWorld 3 4 C 4 UTF 16 “java/lang/Object” 5 6 UTF 6 “<init>” UTF 7 3 “()V” UTF 4 “Code” 8 9 10 M 3 9 N&T 5 6 UTF 4 11 “main” UTF 22 “([Ljava/lang/String;)V” 12 13 14 F 13 15 C 14 UTF 16 “java/lang/System”
  • 33. Constant Pool 1 2 C 2 UTF 10 HelloWorld 3 4 C 4 UTF 16 “java/lang/Object” 5 6 UTF 6 “<init>” UTF 7 3 “()V” UTF 4 “Code” 8 9 10 M 3 9 N&T 5 6 UTF 4 11 “main” UTF 22 “([Ljava/lang/String;)V” 12 13 14 F 13 15 C 14 UTF 16 “java/lang/System”
  • 34. Browsing Class File Format JClassLib Viewer
  • 36. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0
  • 37. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 1
  • 38. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 2 1
  • 39. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 1+2
  • 40. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 2 iadd 3 istore_0 4 iload_0 3
  • 41. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 3 2 iadd 3 istore_0 4 iload_0
  • 42. Stack Based Virtual Machine 0 iconst_1 0 1 2 3 1 iconst_2 3 2 iadd 3 istore_0 4 iload_0 3
  • 43. Operation Types Load and Store Arithmetic and Logic Type Conversion Branch Instructions Object Creation and Manipulation Operand Stack Method Invocation
  • 44. Data Types ac ts refix als ns e P ray oc Co Cod By ture Ar k / L St tan na te Sig boolean Z Integer Types byte B b char C c short S s int I i long J l float F f double D d reference L a void V
  • 45. Parameters and Local Variables static int volume( int width, int depth, int height ) { int area = width * depth; int volume = area * height; return volume; }
  • 46. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, int height ) 2 imul { 3 istore_3 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn
  • 47. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn
  • 48. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn
  • 49. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 1
  • 50. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 2 11ireturn 1
  • 51. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 2
  • 52. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn
  • 53. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 2
  • 54. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 3 11ireturn 2
  • 55. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 6
  • 56. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 6 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn
  • 57. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 6 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn 6
  • 58. Parameters and Local Variables static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t h lum igh h pt a dt { 3 istore_3 de he vo wi 0 1 2 3 4 int area = width * depth; 4 iload_3 1 2 3 2 6 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11ireturn
  • 59. Static vs Virtual Methods static int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t he h lum h igh pt a dt { 3 istore_3 de wi vo 0 1 2 3 4 5 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11 ireturn
  • 60. Static vs Virtual Methods int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t he h lum h igh pt a dt { 3 istore_3 de wi vo 0 1 2 3 4 5 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11 ireturn
  • 61. Static vs Virtual Methods int volume( 0 iload_0 int width, 1 iload_1 int depth, 2 imul e int height ) are t he h lum h igh pt a dt s { 3 istore_3 de thi wi vo 0 1 2 3 4 5 int area = width * depth; 4 iload_3 int volume = area * height; return volume; 5 iload_2 } 6 imul 7 istore 4 9 iload 4 11 ireturn
  • 62. Static vs Virtual Methods int volume( 0 iload_1 int width, 1 iload_2 int depth, 2 imul e int height ) are t he h lum h igh pt a dt s { 3 istore 4 de thi wi vo 0 1 2 3 4 5 int area = width * depth; 5 iload 4 int volume = area * height; return volume; 7 iload_3 } 8 imul 9 istore 5 11 iload 5 13 ireturn
  • 64. Hello World System.out.println( “Hello World” ); 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println 8 return
  • 65. Hello World System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out
  • 66. Hello World System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out
  • 67. Hello World System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out
  • 68. Hello World g s ms thi System.out.println( “Hello World” ); 0 1 2 3 0 getstatic System.out 3 ldc “Hello World” 5 invokevirtual PrintStream.println “Hello World” 8 return System.out
  • 69. Types of Method Invocations invokestatic - invoke static methods invokevirtual - invoke instance method from class invokeinterface - invoke instance method from interface invokespecial - invoke <init> / invoke super method
  • 70. New Object return new BigDecimal(“2.0”);
  • 71. New Object return new BigDecimal(“2.0”); 0 new BigDecimal 3 dup 4 ldc “2.0” 6 invokespecial BigDecimal.<init> 9 areturn
  • 72. New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn
  • 73. New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal
  • 74. New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal
  • 75. New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal
  • 76. New Object return new BigDecimal(“2.0”); 0 1 2 3 0 new BigDecimal 3 dup 4 ldc “2.0” “2.0” 6 invokespecial BigDecimal.<init> 9 areturn BigDecimal
  • 77. If / Else static boolean isPositive( int val ){ if ( val > 0 ) { return true; } else { return false; } }
  • 78. If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn
  • 79. If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn
  • 80. If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn
  • 81. If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn
  • 82. If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn static boolean isPositive( int val ){ return ( val > 0 ); }
  • 83. If / Else static boolean isPositive( int val ){ if ( val > 0 ) { return true; } else { return false; } } static boolean isPositive( int val ){ return ( val > 0 ); }
  • 84. If / Else static boolean isPositive( int val ){ 0 iload_0 test if ( val > 0 ) { 1 ifle +5 //6 return true; 4 iconst_1 } else { if return false; 5 ireturn } 6 iconst_0 else } 7 ireturn static boolean isPositive( int val ){ return ( val > 0 ); }
  • 85. For Loop static int sum( int min, int max ){ int sum = 0; for ( int i=min; i<max; ++i ){ sum += i; } return sum; }
  • 86. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 87. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 88. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 89. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 90. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 91. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 92. before 0 iconst_0 For Loop init & test loop 1 istore_2 2 iload_1 static int sum( int min, int max ){ 3 istore_3 int sum = 0; 4 goto +10 //14 for ( int i=min; i<max; ++i ){ 7 iload_2 loop body sum += i; 8 iload_3 } 9 iadd return sum; 10 istore_2 } inc 11 iinc 3 by 1 14 iload_3 test 15 iload_1 16 if_icmplt -9 //7 19 iload_2 after loop 20 ireturn
  • 93. Exception Handling static int read( InputStream in ) { try { return in.read(); } catch ( IOException e ) { return -1; } finally { IoUtils.closeQuietly( in ); } }
  • 94. 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally 12 aload_0 } 13 invokestatic IoUtils.closeQuietly } 16 iconst_m1 17 ireturn 18 astore_2 19 aload_0 finally 20 invokestatic IoUtils.closeQuietly 23 aload_2 24 athrow
  • 95. 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally 12 aload_0 } 13 invokestatic IoUtils.closeQuietly } 16 iconst_m1 17 ireturn 18 astore_2 19 aload_0 finally 20 invokestatic IoUtils.closeQuietly 23 aload_2 24 athrow
  • 96. 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally 12 aload_0 } 13 invokestatic IoUtils.closeQuietly } 16 iconst_m1 17 ireturn Exception Table 18 astore_2 start end handler Exception 19 aload_0 0 5 11 IOException finally 20 invokestatic IoUtils.closeQuietly 0 5 18 any 23 aload_2 11 12 18 any 24 athrow
  • 97. 0 aload_0 Exception Handling 1 invokevirtual InputStream.read try / finally static int read( InputStream in ) { 4 istore_1 try { 5 aload_0 return in.read(); 6 invokestatic IoUtils.closeQuietly } catch ( IOException e ) { 9 iload_1 return -1; 10 ireturn } finally { 11 pop IoUtils.closeQuietly( in ); catch / finally 12 aload_0 } 13 invokestatic IoUtils.closeQuietly } 16 iconst_m1 17 ireturn Exception Table 18 astore_2 start end handler Exception 19 aload_0 0 5 11 IOException finally 20 invokestatic IoUtils.closeQuietly 0 5 18 any 23 aload_2 11 12 18 any 24 athrow
  • 98. More Attributes... Java 1.2+ InnerClass Synthetic Deprecated
  • 99. More Attributes... Java 1.2+ InnerClass Synthetic Deprecated Debugging LineNumberTable LocalVariableTable SourceFile
  • 100. More Attributes... Java 1.2+ Java 5+ InnerClass Signature Synthetic RuntimeVisibleAnnotations Deprecated RuntimeInvisibleAnnotations Debugging LineNumberTable LocalVariableTable SourceFile
  • 102. Resources The Java Virtual Machine Specification http://java.sun.com/docs/books/jvms/ JClassLib Viewer http://www.ej-technologies.com/products/jclasslib/ overview.html Maxine VM http://labs.oracle.com/projects/maxine/ New Features in Java 6 - Annotation Processing http://www.javabeat.net/articles/14-java-60-features- part-2-pluggable-annotation-proce-1.html

Hinweis der Redaktion