of x

Java Virtual Machine's Internal Architecture

Published on 2 weeks ago | Categories: Documents | Downloads: 0 | Comments: 0

Comments

Content

 

11/18/2010

Java Virtual Machine's Internal Archite…

 Articles |  | News News |  | Weblogs Weblogs |  | Buzz Buzz |  | Books Books |  | Forums  Articles Table of Contents | Contents | Order the Book | Book | Print | Email Email |  | Screen Friendly Version | Version  | Previous Previous |  | Next Sponsored Link  Link • Building a Multi-P Multi-Page age Image Viewer Viewer with ImageGear ImageGear for Silverlight and Az Azure ure

             

                                                                                                                                       

                                                                                          Г Г                                                                                                                       

 Г                        artima.com/insidejvm/ed2/jvmP.html

1/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                   main()       main()       void         String        main()                          // On CD-ROM in file jvm/ex1/Echo.java class Echo {               }

public static void main(String[] args) { int len = args.length; for (int i = 0; i < len; ++i) { System.out.print(args[i] + " "); } System.out.println(); }

                    main()                     java             Echo     java              java Echo Greetings, Planet.

      java                                    Echo              Echo         main()    void     String           Greetings, Planet.               main()     String                       String       Echo   arg[0]   "Greetings," arg[1]  "Planet."  main()                                                                                                      main()                                                           exit()    Runtime   System   Echo    main()         artima.com/insidejvm/ed2/jvmP.html

2/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

      main()                

                                                                                                                                                                                                                 

         

                                                               artima.com/insidejvm/ed2/jvmP.html

3/46

 

11/18/2010

Java Virtual Machine's Internal Archite…                     

                                                                                                                                                                                                                       

           

                   artima.com/insidejvm/ed2/jvmP.html

4/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                

                                                                                                                                                                                                                                

artima.com/insidejvm/ed2/jvmP.html

5/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

        

                                                                                                                                            

                                                                                                                         

artima.com/insidejvm/ed2/jvmP.html

6/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

        

                  boolean                                       int  byte   boolean      false        true        boolean   int   boolean       byte                 byte               boolean                    byte  short  int  long   char       float  double                     long                                       returnAddress          finally         returnAddress                      reference    reference                                                                           null      reference                                                                                 byte



short int

            

 

               

 

               

 

long

 

               

char

 

                

float double

 

             

            

returnAddress                artima.com/insidejvm/ed2/jvmP.html

7/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

reference

 

          null

         

                                                               byte  short  int  char  float  returnAddress   reference             long   double 

                                            

                                                                                                            

  Г                                                                                                                                         

                  java.lang                java.lang.ClassLoader     ClassLoader                            java.lang.Class      Г          Class             

Г Г   Г                  artima.com/insidejvm/ed2/jvmP.html

8/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                    Г             Г Г                                                                                                     Г   

   Г                                                                                                                                                                           CLASSPATH                CLASSPATH                   .class                           CLASSPATH                           java.lang.Object      Object.class   java\lang    CLASSPATH                                                      CLASSPATH                                                                                 Г 

    Г                  ClassLoader        artima.com/insidejvm/ed2/jvmP.html

9/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

// Four of the methods declared in class java.lang.ClassLoader: protected final Class defineClass(String name, byte data[],   int offset, int length); protected final Class defineClass(String name, byte data[],   int offset, int length, ProtectionDomain protectionDomain); protected final Class findSystemClass(String name); protected final void resolveClass(Class c);

              ClassLoader          defineClass()    byte  data[]                  length   ClassLoader        offset                                             name                defineClass()             protectionDomain           defineClass()     ClassLoader              findSystemClass()     String                                                                                           Class                 ClassNotFoundException     findSystemClass()                      findSystemClass()                        resolveClass()       Class          Class             defineClass()              Г Г         defineClass()   Class                               resolveClass()    ClassLoader                                    Г 

                                                                                                                                           artima.com/insidejvm/ed2/jvmP.html

10/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                               Г 

                                                                                                                                                                                                                                                                                                                                                                                                                      Lava      Lava                                                                                                                                                                       Г    artima.com/insidejvm/ed2/jvmP.html

11/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                  java.lang.Object                                   public  abstract  final                                                                   Object    java.lang   java.lang.Object            java/lang/Object                   

                                           ClassLoader     Class        

                                                                                                              

                                                       artima.com/insidejvm/ed2/jvmP.html

12/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

      public  private  protected  static  final  volatile  transient

                                                      void                 public  private  protected  static  final  synchronized  native  abstract                                                              

                                                                                                                                                                                 

    ClassLoader                                                                                                                    artima.com/insidejvm/ed2/jvmP.html

13/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                Г   

    Class     java.lang.Class                         Class                       Class       Class                   Class      // A method declared in class java.lang.Class: public static Class forName(String className);

   forName("java.lang.Object")                          Class  java.lang.Object forName("java.util.Enumeration")              Class      Enumeration    java.util     forName()    Class                                           ClassNotFoundException forName()       Class     getClass()              Object  // A method declared in class java.lang.Object: public final Class getClass();

          java.lang.Integer                Class   java.lang.Integer    getClass()       Integer       Class                Class             Class                        Class // Some of the methods declared in class java.lang.Class: public String getName(); public Class getSuperClass(); public boolean isInterface(); public Class[] getInterfaces(); public ClassLoader getClassLoader();

         getName()          getSuperClass()   Class             java.lang.Object           getSuperClass()  null isInterface()  true   Class     false      getInterfaces()     Class                               getInterfaces()       getClassLoader()     artima.com/insidejvm/ed2/jvmP.html

14/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

 ClassLoader       null                    

                                                                                                                                                            Г 

                           // On Lava CD-ROM class { in file jvm/ex2/Lava.java  

private int speed = 5; // 5 kilometers per hour

    }

void flow() { }

// On CD-ROM in file jvm/ex2/Volcano.java class Volcano {         }

public static void main(String[] args) { Lava lava = new Lava(); lava.flow(); }

                 main()    Volcano                                  Volcano main()     Volcano      Volcano             Volcano              Volcano.class       Volcano                        main()                 main()                                    Volcano               main()    Volcano         Lava Г                 artima.com/insidejvm/ed2/jvmP.html

15/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

          main()         main()                            Volcano               Lava         Lava    

             "Lava"                                                        forName()    Class          Class                     Lava               Lava.class        Lava                                        Volcano          "Lava"                Lava         Volcano                        Lava        "Lava"               Lava                                                                                      Lava                         Volcano       Lava                      Lava                                                                                     Lava              speed          Lava  Object                                      Г       main()         Lava                     speed                 flow()     Lava  artima.com/insidejvm/ed2/jvmP.html

16/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                              

                                                                                  OutOfMemory                                                                                                                                                                                                                                                                                                      artima.com/insidejvm/ed2/jvmP.html

17/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                                                              

artima.com/insidejvm/ed2/jvmP.html

18/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

           

                                                                                      

          

                                                                              instanceof                                                                                                                          artima.com/insidejvm/ed2/jvmP.html

19/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                          Г   

artima.com/insidejvm/ed2/jvmP.html

20/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

        

                    Г                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Object          wait()     notify()   notifyAll()                                                                                                                                                                       artima.com/insidejvm/ed2/jvmP.html

21/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                                                                                                                                                                    

          Г                            Class                                                      int           int                                             int  "[I"         byte  "[[[B"          Object  "[[Ljava.lang.Object"                                 int                   int       

artima.com/insidejvm/ed2/jvmP.html

22/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

       

                                                                       Object       

                                           returnAddress                                                       

                                                      artima.com/insidejvm/ed2/jvmP.html

23/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                                                                                 Г                                                                               

                                                                                                                 

Г                                       int  float  reference   returnAddress             byte  short   char    int           long  double                            artima.com/insidejvm/ed2/jvmP.html

24/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

           long            long             long  double                                                // On CD-ROM in file jvm/ex3/Example3a.java class Example3a {    

public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) {

   

return 0; }

   

public int runInstanceMethod(char c, double d, short s, boolean b) {

    }

}

return 0;

            

              runInstanceMethod()    reference                          this                           artima.com/insidejvm/ed2/jvmP.html

25/46

artima.com/insidejvm/ed2/jvmP.html

25/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

         runClassMethod()           this                                  byte  short  char   boolean       int                 boolean                int   boolean           byte  short   char

                                                             byte  short   char    int     int            byte  short   char            Object  o       runClassMethod()                                                                                                               i  j    Example3b                          j           i         i            j // On CD-ROM in file jvm/ex3/Example3b.java class Example3b {  

public static void runtwoLoops() {

     

for (int i = 0; i < 10; ++i) { System.out.println(i); }

        }

for (int j = 9; j >= 0; --j) { System.out.println(j); } }

                                 long  double                                         

  Г                                                     

artima.com/insidejvm/ed2/jvmP.html

26/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                   int  long  float  double  reference   returnType      byte  short   char  int                                                                                                                                                    iadd        int             int                int    int       iload_0 iload_1 iadd istore_2

// // // //

push the int in local variable 0 push the int in local variable 1 pop two ints, add them, push result pop int, store into local variable 2

         iload_0  iload_1       int              iadd     int       int          istore_2                                                                   

artima.com/insidejvm/ed2/jvmP.html

27/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

     

                                                                   int  long  float  double   String                                                                                                                                                                        

artima.com/insidejvm/ed2/jvmP.html

28/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                                                                                 

                                                   // On CD-ROM in file jvm/ex3/Example3c.java class Example3c {        

public static void addAndPrint() { double result = addTwoTypes(1, 88.88); System.out.println(result); }

      }

public static double addTwoTypes(int i, double d) { return i + d; }

               addAndPrint()                         addTwoTypes()    addAndPrint()     int   double          addTwoTypes() 

artima.com/insidejvm/ed2/jvmP.html

29/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

      

    addTwoTypes()                        addAndPrint()         addTwoTypes()           Г                                         addTwoTypes()                 addTwoTypes()                 javac      addTwoTypes()                                    addTwoTypes()         double  int       addAndPrint()       addTwoType()        addTwoTypes()      double                              addAndPrint()    double     addAndPrint()         addTwoType()  

artima.com/insidejvm/ed2/jvmP.html

30/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

 addAndPrint()       addAndPrint()        addTwoType()                                                                              addAndPrint()         addTwoType()    

       

                                                                                                                                                                                            

artima.com/insidejvm/ed2/jvmP.html

31/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                            

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

artima.com/insidejvm/ed2/jvmP.html

32/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                      

                   

                                                                                                                                                                     

                                                                

artima.com/insidejvm/ed2/jvmP.html

33/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                   

                                                                                                                                                                                                                                                                                                                                                                               

artima.com/insidejvm/ed2/jvmP.html

34/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                      goto   return                                                  athrow                 throw         athrow                                              ArithmeticException         idiv  ldiv  irem   lrem       int  long                                                  doMathForever()     // On CD-ROM in file jvm/ex4/Act.java class Act {               }

public static void doMathForever() { int i = 0; for (;;) { i += 1; i *= 2; } }

     doMathForever()                                                                                                 // // // // // //      

Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9 Disassembly: Method void doMathForever() Left column: offset of instruction from beginning of method | Center column: instruction mnemonic and any operands | | Right column: comment 0 iconst_0 // 03 1 istore_0 // 3b 2 iinc 0, 1 // 84 00 01

artima.com/insidejvm/ed2/jvmP.html

35/46

 

11/18/2010

         

5 6 7 8 9

iload_0 iconst_2 imul istore_0 goto 2

Java Virtual Machine's Internal Archite…

// // // // //

1a 05 68 3b a7 ff f9

             javap        javap                                 goto               iinc                                   iinc                               goto -7     goto 2                                                                       iinc                                                                                                                                                                                                                                                                                                                                                     .o   .obj                                                                                           

artima.com/insidejvm/ed2/jvmP.html

36/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                                        istore          int    fstore         float                         int    float         

                                             int    float                                dup                   goto                                                                                        arraylength   instanceof   arraylength        instanceof         

  

   

byte

b

baload    byte  

short

s

saload    short  

int long

i l

iaload    int   laload    long  

char

c

caload    char  

float

f

faload    float  

artima.com/insidejvm/ed2/jvmP.html

37/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

double

d

daload    double  

reference a

aaload    reference  

      

                       int         long       float               int             double                          reference                                        dup                            int  float  reference   returnAddress       dup          long    double                   long   double                  dup2                                                           byte  short   char      int                  int     byte  short   char                                                                                                   

                     

byte

 



int

 



short

 



int

 





int

 



int

 

long

 



long

char

 



int



float



double



reference

float double reference

     

 



 

  

  

  



          

artima.com/insidejvm/ed2/jvmP.html

38/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                          Г                

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

artima.com/insidejvm/ed2/jvmP.html

39/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

artima.com/insidejvm/ed2/jvmP.html

40/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

              

                                                                                                                                                                                      Г                                                                                                                                                                                                                                 wait()  notify()   notifyAll()    Object                                                                               Г                                                          long  double         

artima.com/insidejvm/ed2/jvmP.html

41/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

      int                                                                        long  double      volatile                           long                 long  double             long   double                   long  double                 long  double                                                                                       long  double                                                                                                                                                                                                                   

                                                                                                                

artima.com/insidejvm/ed2/jvmP.html

42/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                    Г                    Г                                                                                                                                                                                        

                                                                                                                          

artima.com/insidejvm/ed2/jvmP.html

43/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

                                                                                                                                                                                                  

                                              applets/EternalMath.html                           doMathForever()    Act                                                                                                                                                                    iconst_0                 iconst_0                                                                                                                                                                                                                   doMathForever()       i                    iconst_0  istore_0        

artima.com/insidejvm/ed2/jvmP.html

44/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

 iinc      i       i += 1   doMathForever()    iload_0                         iconst_2   int      imul      ints            istore_0                      i *= 2   doMathForever()    goto           iinc    goto    for  (;;)    doMathForever()                                                                          

     

               jvm                   applets/EternalMath.html               applets/JVMSimulators   applets/JVMSi applets/JVMSimulators/COM/ mulators/COM/artima/jvmsim artima/jvmsim 

                  

artima.com/insidejvm/ed2/jvmP.html

45/46

 

11/18/2010

Java Virtual Machine's Internal Archite…

http://www.artima.com/insid http://www.art ima.com/insidejvm/resources ejvm/resources/ /                                 

Sponsored Links Free online Flex training training Download the OpenSource Flex 4 SDK Explore Ex plore Flex Capabilities - Install Tour de Flex Programming in Scala - Download PDF eBook now, only $27.50 New today!Adobe® Flash® Builder™. Download yours

Copyright © Copyright  © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy Policy  - Terms of Use Use  - Adv  Advertise ertise with Us

Sponsor Documents

Hide

Forgot your password?

Or register your new account on INBA.INFO

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close