Sie sind auf Seite 1von 46

11/18/2010 Java Virtual Machine's Internal Archite…

Articles | News | Weblogs | Buzz | Books | Forums


Table of Contents | Order the Book | Print | Email | Screen Friendly Version | Previous | Next
Sponsored Link • Building a Multi-Page Image Viewer with ImageGear for Silverlight and Azure

 
  
 
 









 


!   




!
 
   "#  ! 


 
!
 

 
!   

!   

   !    $$       
!     
 
 
     
!% 
   
 !! 

  
 
    !    

   
!   
      

   % 
%   


 
 
!! 

& '

   ! 
! 
 ! 

 
    
$!  $(
! 
)

 
%

!! 
%

 !  

  


 
%    

)  
   
   %  ! Г 
!   +  (  
 !! 
%  ,

!  
!   
! 
! !   
%    

  
! 


 
 " !  
   

-  


       !   
 
! 
 !! 

 
 

!   

%!$! $
 
  &   
 
!
,%


!$ 
%$$!! 
%$
$  $
!$! $

Г !
 
"  !   
    !     !
    ) 
  
 

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
! 
!0 1023
 
   
    Echo 
   0  java
 & 
45%
 ,!% 


 
!! )

java Echo Greetings, Planet.

 
 
!! %$java%$ !  
!0 1
023
 
 ! 

%$Echo%$ !
 
  Echo !     !
 ! main()    void    
String   
 !   6  
% $Greetings, Planet.%$  

!!    ! 
  
    
  main() !
   
String    
     
  
!!     0
%
  

,!%  
 
  String   
 !    Echo ) arg[0] 
"Greetings,"arg[1]"Planet."

 main() !



   
         
 
 

       



! %
! 
 
)  "!

 
      !   %     
!



%
% ! !

 
 
..
 main()..
.!


"

 
,7!   
 
8

 
.!
       & 
.!
 
  

! %   !      ,   !    ! % 

 
 
 !  
  exit()!

  Runtime

System

 Echo

%  main()!
 
  
 
  " 
artima.com/insidejvm/ed2/jvmP.html 2/46
11/18/2010 Java Virtual Machine's Internal Archite…
 
 
!!   ! % main()   !  



.!
%!   
,

"
 
!  
%

!   
!
!%!!
%%  
 
!
 
 
!  


!
 


!
  
!! 
  !




     ,  



 !! 
    
     6


 ! !! 
 !

!
  
 


+ .9

!
!  !:
!
  !!
     
 " ! 
  
 % 
 !      
    )  ! !
 
   7  
  8  6  ! -! 
    )
! !

,  

  !





    

& !  


!%  !!


!  %  

  
 
!
  , 
! 
  %
:  
!
  % ! 
 !
%   % 
 %    ! 

artima.com/insidejvm/ed2/jvmP.html 3/46
11/18/2010 Java
  % ! 
 !
% Virtual%
  Machine's Internal

 Archite…
%    ! 


!
 ! 
 ;!!
 
,
! 


  


"
  !  !   ,   
!
!      ! 
!! 
% 
6  



 ! 
 
 !! 


2   !! 



   !         !!
 
 
0
!!! 
!

!!
 

%
!
0
!!! 
 ! 
  
 !!
%
 !
  
 
  

  !   ! 
 !! 
! 


! 

0
! !!

 
 
 6

  -  
! 
 
 

              !   &   
! 
  %  
!

  
!   
 
   
!
 
!
 "
! %
! 
:
!  

 0+ .1



!!


    

"   


!  
, %  
  
  
 7
!
 8   

artima.com/insidejvm/ed2/jvmP.html 4/46
11/18/2010 Java Virtual Machine's Internal Archite…
   , !
7
 !
8%

  , 

, "

7
 8
!
  


     
   !
  

    

% !     
%    7   8%   !

   
  !
  

  
     !! 
.  
      %   
  

 !! 
.  
!!


   


!

  
 7
 
8  "  ! 
   


!
 

&  
!
%!  
!

   & !
 
!%!  
 
 !
!


   !  


  
 
  !      
 
   
 

  !     
     
  
     !   
  
!   
 
!! 

  
 
   
% 
. 
    !   
    


!;


:. .!  !
!
 .! 
!
! !! 


0+ .<


!!
! 

 

   =
 





artima.com/insidejvm/ed2/jvmP.html 5/46
11/18/2010 Java Virtual Machine's Internal Archite…

    

+ .<
  

 !     , 
"  
 
%
  
, !
  
,  !


 + .<%    



     

%  


 
  $
$

  

!
  0 !

   ,  !
  
        +
     
,  !
%     ,  

 ,   + .<%
7


 
8
   
 ,  !
%
 
..

  
..   

2
 ! 
!
! 


 
  
 
 

  !  

   

 
    

   
  !
 
 
   %   
      


    >  
 

:%

:! #!%
%

 

         !  (


      

  
!  !
 + .?

artima.com/insidejvm/ed2/jvmP.html 6/46
11/18/2010 Java Virtual Machine's Internal Archite…

   !  

"!

!!  !

!   "
 boolean 6    ! 
    ! % 
 
  ! 

  &  
!   

  


%  int
 byte 
   boolean      ! % false 
    ;
  true  
.;
    /
 
  boolean
  int  "
 boolean    
 byte% 
  ! 
 

byte
 

 ! 


  
!!   
   boolean
!   


!   !   
  )byte%
short%int%long% char%      )float  double "

!!   %  ! 
    !    !  
 "long ! @?. 

!! 
!%   
  

!

   !  


 

 !      
  

!!)  returnAddress    !    
 !!  finally

 
! 
  returnAddress    
95%$+  $

    


    !    ! reference  
 
reference
!   
)    %  
 %   

   " 


     
  ! 
:    
   
              
 %   .

:      !             
 
    !!        / 
       null % 
 reference
  
 
:

!  


   


%


  ;  !





 
 !! 
  
!  
 
     .9  
 
!

  
  
          9?%
$+
 #
 "! $

! 
byte 5. 

!!  7.1A
1A.9% 8
short 9@. 

!!  7.19 
19 .9% 8
int <1. 

!!  7.1<9 
1<9.9% 8
long @?. 

!!  7.1@< 
1@<.9% 8
char 9@.  B 
7C
19@.9% 8
float <1. ---A ? .
 

double @?. ---A ?
.
 

returnAddress 
 

 !!


artima.com/insidejvm/ed2/jvmP.html 7/46
11/18/2010 Java Virtual Machine's Internal Archite…
reference   
 
:
%
null

"
  # !

&
0;
 
;
  !  
.. , ; 

   
    !  !! 
  
 ; !  

 
 
  
  byte% short% int% char% float% returnAddress%

reference  
 
 !   
 
 
  
  long
 double  "
!! 
 !



; <1%

  
; !
   !! 

; 


 
;
 
 


!

  



 ! 
  !   !   
 
 

 
  +
 ,!%
 

   !..
 
 
 ..    !

   
 
  
 
 !     &    
  
 

  %  







"   %  


! 
 !   
 ;
  
  ! 
!! 
 
 ;

  

 
!  
    

! !! 

Г
0!

! !! 

    
 
   
     9% $ 


  "%$  


 !  <% $0%$ 
 
 !   
  !

    
!   !
   
 
  
 


!
 
!   

" ! 
    9%    !  
  
  
  
) 
 
   
   
    
   

  
   
 
 !  !! 
%   .    
  
     

 
    
  
     
! 

  
 !  
 ! 
 
    !    
 
!  java.lang   +
 ,!% .    
   

: 
    
! java.lang.ClassLoader   !

 
ClassLoader 
  
 
    !   
  ! 
"
%
      !  
%       
 
java.lang.Class 
      Г 
:% .    
  
  
Class
 2

 !


Г
 %Г    ;

  
!  

 !
  : 
   !
    

artima.com/insidejvm/ed2/jvmP.html 8/46
11/18/2010 Java Virtual Machine's Internal Archite…

    ! 
    
 
 !
 % 
    ;
!!

%  


!
   

! 
)

9  Г
 )    !
  

1  Г  )
!  
%
% 7

8


   
)  
 
!

  #
) 
  !!

      ;   !!
 

 
  >

) 
! !
   
! 
  
<  ;
)  
   
   ;   
  
  




 A%$Г !
 $



Г


 ! !! 


! 

 ;  
     

       

! 
    
!  "  !! 
   


 ;
 
! %!
 ; 

-   !  !! 


   

  
%  
 
 


%   
 "#  !   


     
  

 
 
 
     
 
 
 

!! 
 

D    6   !%  

  
 !    ! 


          /  
!!
 
  !
   
! !! 
 0 9 923
& 
45 !! 

.  

   
!  ! CLASSPATH 





 
% 

  CLASSPATH%   
 
 !)! !$.class$ B 

  ! %  

 
 ,   
     


 

 CLASSPATH  !

 
! !

 +
,!% 


 
 java.lang.Object%



Object.class java\lang

CLASSPATH


 9 1%  

  

 0   1 023
 

    


    
!  7  
   "# 8      

  

 
!! 

    !  
! 0   1 023 

 


 
CLASSPATH  0 1023! % :

 
  
%  .    
    
!     ! 
 

!


 !
0 1023  
5%$Г  
 $

B.2  Г


"
 .    
 !  
   
%

 
!
 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[]%    0 


 offset      
  
 length %  ClassLoader ,
  

! 
  
!..     

  
.. 6  !  name  

    

 
! %     

 defineClass()  %
 
 


 
! 
:     protectionDomain !  -  
!  !! 
 ! !   defineClass() !

  ClassLoader
  
!
 
!


 findSystemClass() !


   String      6  !
 
 & .  
 
!
 
9 C 9 9%6 
   !  ! 
 
  !    

  
   


 
 

  
%     

 Class
:         
    
 %  

ClassNotFoundException  
9 1% findSystemClass()!
!


6 
!!
 -! !! 
!
!  findSystemClass() !
   
 

7  
9 C
9 98

!7 
9 1
8
 

 resolveClass()!
   
 Class    !
  
     Class    
    7         8  
defineClass() !
%  
%
  
 
   70  


% $Г
 % Г  %   ;
$
   

  ! 8 &
defineClass() Class  %  
   

  !
  
  !
 % 
       ;   
! !! 
 !  resolveClass()!

 ClassLoader 

!

!  



! 
!
 %  %  ;
%
.  
  5%$Г  
 $

=!0

"! 
 <%$0%$
!  
  !

     
     
  
  ! %    

  
 !   ! 6  !  "   6 
!% 
% 
  
 
  6          ! 
    ! 
 ! !   
  
    !% 
 


7 
 ! 8


 6  

=!   !    







artima.com/insidejvm/ed2/jvmP.html 10/46
11/18/2010 Java Virtual Machine's Internal Archite…
"


%! 


!
 & !  

!
   
!

 
 
%  6      
!  !  
  
 
    
  5%$Г  
 $


"
!   %
!



 


 !!
  !
  &   !  
 %   




  
  .. !

 .. 
!  ! ,
!


 
!   
 
!
  !
 !


78 
  
!!


 !        !  !! 


    
!

  

!! 
  +
,!%!.6  
 
 .   7!
    8
 &   !
 

 !
 % 
%   !    
       !    
!! 
 
 

 .  

%   !  

 !.
 !
 .  


! 
 
!

 !

 ,
 
   2 !! 
 
   ,

   
%  ! 
  
 
!  
     !! 
  
   
 !!
 
 %   !



!,
  


!      !! 

   
   !!
 !%
 
  %   !  
 

   
!
    !
  
  ,
   7      


 
!!
%

% 

 
!!
!
!! 
82  


 
 ;
  
!;  !! 
 
! %    
,
 
6! 

"  !!


 %
 
 !
  !
  
  .    
   !  
     ! Lava%

,!%  Lava
  
%

 
 


 




;
!
  
 , " 
 % ! 
 ,  
!

  
  "
%!!


!
  
  

   
  

  .. 
  
! 
   !! 
!


!!
   ;

!
%!,!!
! !!;

 !
    
   
    
!     !
, .  
% 
!$   $
 
 
!    %    !     
   7 
 8 

  !!



   !
    ! !!    
 
 ..
  

  
!$   $.. 
A%$Г !
 $
artima.com/insidejvm/ed2/jvmP.html 11/46
11/18/2010 Java Virtual Machine's Internal Archite…


!

+

%! !


  

!
 
!
)

 6  !



  6  !
     7         

java.lang.Object% 
8
&


   
!
 7
!
Epublic%abstract%final8
" 

 6  !
   

  ! % !


    
  

% 6  ! !
%
%
       +
 ,!%   6  !
  Object   
java.lang  java.lang.Object    %  
    %  
java/lang/Object   !
% 6  !    

!  






!

%! !




)


 



+
!



!

"78 %,
 
"  
ClassLoader
"  
Class

 

 



 #

+
   
%  !  ! 
     " 
 

  

 
 
     %     7 %  %   
  
 

 8 !
  
% % !
 -  
 


   ,%!! 
  
!
  

% % !


%
 

 
  !
  

! 
 

 !
  
@%$+ $

+
!

+
  %

 
!
!
 !




!

 %
  

  !

 F
 )

  !


 

artima.com/insidejvm/ed2/jvmP.html 12/46
11/18/2010 Java Virtual Machine's Internal Archite…
  !
  7
! 
 public% private% protected% static% final%
volatile%transient8



!

+
 !
    % 

  
!
!  
   !

 " %
 !

  !

 F)

!
 !
!
 7
void8
 ! 7 
8
!
!
 !
!
  7
! 
 public% private% protected% static% final%
synchronized%native%abstract8



!
%

 
!
!


!


 )

!


 ;
 
     
  

  !
  !
7 

8
" ,
7 9A%$-,
$8



!
  
     

        
  ..
   
 ..



 !
 
! 
%!
!!
 
!!


.  



  7    8 
     !  
.   
 -    


   


 

 "

 

%  
 !
..:

.    
.   

 

 
!%  


 
! ! 

 ,  !
 @%$
+ $

">  


ClassLoader

+
   
%    !  ! 
 

  

 

 

 .   
 +

 
 
.    
%   !  ! 
     
  .   

  
    
!
  
 
      !



  !    


!
    !     & 
    


 %   !  6      
!  !  
 

    

 !  
 

artima.com/insidejvm/ed2/jvmP.html 13/46
11/18/2010 Java Virtual Machine's Internal Archite…
! 
!  !   
   
 
 
!  !     
!  ! !%!  




 !
 
 !    !  5%
$Г  
 $

">  


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   


   
  
!   % 
 
       7

 8
 
  !  !  


6 
  !%forName()
ClassNotFoundException

"   


  Class    
 
 getClass()
 
:   
!
 
: 
!Object )

// A method declared in class java.lang.Object:


public final Class getClass();


  
 
:
java.lang.Integer%
,!%


Class
:
 java.lang.Integer !  
  getClass()
 
    

Integer
:

D     


 Class
:% 
   
 
!
 
    
 
!
  Class  


!
%
6;
Class     
 
  
!

    !
  F

!
!
 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()    
6  !
   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   
 



 "
!

!

!





 
!
 
   !
  ! 
 ; 
  6 


  
!
 
%!! 
 ! 
 

 / ,!
 
  +

. ! 
%
  !

   

!
 
 !
 " !


     
      !
  !   

     %
    !
  
! 7" !
    


  %
!    8"!


   !  
 6 
      !
  

  
:  

  5%$Г  
 $

" -,!

"B

" ,!

! 
!

 !
%

)

// On CD-ROM in file jvm/ex2/Lava.java


class Lava {

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
2   !! 


!   
     

 


 ..
 
 ..   !  
 ,    


Volcanomain()!



  Volcano
%
  !$Volcano$
  !    
!! 
.   !   D   ! Volcano%   !     
   Volcano.class  ,  

 Volcano 
! 
!
  
!
 
!
 ! 
 
  main() !
%      
 
    !
   " 
! , main()%!  
 

 

7
!
8
 7Volcano8

=
     !     
 ,  

 main() 
 Volcano   
     
  Lava  Г !  7
 !
8
!! 

    ! %  !! 
 
      
artima.com/insidejvm/ed2/jvmP.html 15/46
11/18/2010 Java Virtual Machine's Internal Archite…
 
 

   ,  main()   

 
!

main()   


 !  

 
!!

 
   
  

  
    !    
   
 Volcano 
 





 
   !
  
Lava  !


 Lava 


!
  :    6  !) "Lava" F 

 !
!
 ;
 
..6
..
 
    6  !  !! 
     

 

!   ..%%   !
! ! forName()!

 Class%  Class
    6  !

& ! 


 
 !$Lava%$


        Lava.class   ,    



  Lava 
!  !

  
!
 
!


 !  !


     Volcano
  

  

%   :    "Lava"%   
  
   
 Lava    
! 
Volcano
 

 
 %







 
!

Lava 
!

  %  "Lava"   :
 
!
6

Lava  

  !
       7   % 

 8   
  !
  
  
  
 
!
    
 %
  


+ %   !   


  
 !!

   Lava
:  / 
 %! 

!

 !
  
 
7  :  
 Volcano 
  

  
8 
  Lava  7  :
!
 
!
8
  

!6Lava
:

"   !     !  !


 
 !!
 6 
   

:

  

 !
 !
 

6   
:% 
%  !! 
.       
 


:      !   
 

 !! 

  /: 
 !
 

/     !   !   !


 
   6   Lava

:% 
 
    ;     speed 
;
% 
     Lava% Object%   %


 ;
   7
 ;


 
:
 A%$Г !
 $8

  



main()
!   
 Lava
:


  "   
       
  
  
   ;  speed
 
  
   %   "
  
       
  
 
flow()!

  Lava
:

artima.com/insidejvm/ed2/jvmP.html 16/46
11/18/2010 Java Virtual Machine's Internal Archite…

F
&   
    
% !!



:
 
!  "

 ! 
  % 
  $
 $,
!   %   
     
 

 
     
 
 !
 
    
   

 ! 
%
% 
!

    

 ! 
  

  
;

!.  

: 7
8 

!

!   



!!


 
:%

 

  !!
  
 ,  
: 

 
% 
   ,   
:    
    !    


   
 !!


:


        
 B%    !  !! 
  

  

! 

D


" 

 !  
 
 
! ! !!
 
:
 
 
         
  ! 
 !

:  

 
 ! 

"  

 
  6     !   
 
 

 6    !! 
 !  
     
 +

,!%   !! 
 
 !   , !
 
     

  OutOfMemory,
     &!! 
 !

 ! ;%
6 !  !  




!!!
 !! 
!!
  
!
 

  
   !! 
 ! !       
 !! 

 

!
 !!
 
!%
    

 
 

 
 

=
 

 6   !   
 2 
     6 ! !
 
    
% 
 %    
   

:  ,  !  .. 0% % !
 %
!
..



 6   

  !! 
 !   
 

 6  
4%$D

$

"!
%!!
! 


% !
 ,    
      
! 
  "  !! 
 !

 
%  % !! 
 

   

%    ! 
!!

 
%
!!
 
!!


:   !  

  !!

    
:

  
        7 
 8       !! 
 !

 
 
!! 
       ;
  %     !,!!  
! !!;

artima.com/insidejvm/ed2/jvmP.html 17/46
11/18/2010 Java Virtual Machine's Internal Archite…

/:> 

!  


 


:
 

/: 
..  

 
 

..


!! 
 

!! 
! 

:  
 
:  D  
:  %! 
!  
6 
   

:   
% ! 
!

 
:7
 !
8   

: +

 
%  !!
 

  
:    
!  
 
   
 
!


/ 
    

 )  

  
: 

 "

:       
  
    

    "   

    


!
 )
 
   
:

 
 
 !

  
!!
! 

!
! 
& ! !
 
: 
:

% 


 
   
:  )    
       

  
 
  
     
  
:     6
   

  


: 

  +
.    
   !
     F/ + %  
4%$D

$

artima.com/insidejvm/ed2/jvmP.html 18/46
11/18/2010 Java Virtual Machine's Internal Archite…
  $!"% !"%!

"
  ! 
:    
  
 
 
 

:   
 

: 
6   



 
 
:  %!!
 
:!

!
& ! !
 
:

! ! 

 
%!
  

:   ! 


:
 

  + .@

 & '!"%!

  !   


  
!  
:    
 
: 
 

 &   
!!
 
:  

%
! !
   

  
:



      ! 
!  !  
     
! 
! 
instanceof

  %   !  ! 

  
  
 
  
:  &   
!  
      !
%   !  !

!  !   )  ! 

  !


 
  
 

  
 
  


: 

%!
 

 
  

:

=
! 
: 
  !! 
%  !
 

   
 
:  
 %       


   
!
%  !
 
  



! 
! 

artima.com/insidejvm/ed2/jvmP.html 19/46
11/18/2010 Java Virtual Machine's Internal Archite…
!! 
 
  
 6     !   
  
!
 ,    !! 
  !! 
   ,! 
 !!

6! %
   % !
   
 
  , !!
  !
 

     !! 
 
  !
 % 
%  
: !
  
6 :  

:

/     !! 


 
 
  !
  
  
:     

 + .A  

   


:
 
 

!
 )

"
 
 

:
!


:!
 

 


  !
    


:
   !
 
 

!
 )
;

  


!

!


" ,


    !  


 
!
 
  
  !
   !
 
  
  
 
 !
  ,   
: 
   
!
  

%
  !
!
 
!
   

:
 
 

!

!
  5%
$Г  
 $

artima.com/insidejvm/ed2/jvmP.html 20/46
11/18/2010 Java Virtual Machine's Internal Archite…
 ( '!  " 

 
  !     
 
 GG% 
 ! 
 ;  !
  
! 
  Г
  
 GG
:   GG%
:     
   

 
   
  


:



 ! !! 
" !! 


 

!


!
  

 


!!
 

  +
.A%  !    
! 
  !   :
  6 

!!


/ 
 


  + .   .@%



:
 %
:  -
:  !  


7
  8
! 
 

 !.

:
/ 
! $
 $ 
:
 &
 

: 
%
      
:      "
  
!
 
: 
  
   
:

   6 
 
 
 % 6 

 
  
 / 
 
% 6
!
 !!% 

! !
!

  !  

      6  
  !%
 ,!% 

 

 
 !

 
:  
 
     !
    
     
6
!!  
:

  
6
 "%! !! 
%

  + .   .@%!

 
 
$
$ 
: 0!! 
!

 
 
6
 !  !%
! !


: 
! % 

 


:

"
  !!  
% 
: 

  
!!   &


   


    
 
%     
 

 
 
..
 




!!



& 
: 
 
 !
 -  
!Object
$!
$7


!
!
 ! wait()8 
 $
 !
$
7notify()   notifyAll()8  &     
   !

  
:%  
!   

: &  


 !

 
:%! 
! !

!

 
!
: "!!  
:
%
!!  
: 
  

 !
  



: "%! !! 

! !
   
!  
:   0 !! 
 
 
  
 
    
:      

  !
    

 

:    
+
 !

!

 
  %  
1C%$0 
;
$

/ ,!

! 
!
 
:


artima.com/insidejvm/ed2/jvmP.html 21/46
11/18/2010 Java Virtual Machine's Internal Archite…
  

 

! 
!

 
:       
!      6  
 


:
  
6 



 6     +
 ,!%     !! 
   
   
!% 
!   
!  
:    
      +
    
:% 
!
 
 


:  ;  "
%
!  
!
:! 0
! 

 6

6  ,     

       " !   

!%
   % 
 
     !
 !      
   
: 
 
 
 

 6%    
6
!%  4%$D

$

 
 
     

  
         
   
:%  

   
 

:
 
  ,   ;  D 

 !     ;
  
: 

 
 
  !  !!

  
:     
 



, 
:  ;
%

  ; 
 $$ 
:) 
 ! 
:      &  
:

!   

!%

!
  ; 
!

:
  ;%  


:%
 


 !
:
,! "%
 
 

:    ;% 

 


 
:%


: 


 !
 %  

    
!
        4%
$D

%$!

!

  ;

"> 

 %  . 


:  Г
:%   

   "


:%!! 
  
 
 


" Class  


%: 

: "

!! 
 !  
 7
 

! 

 !! 
 8

   
     
+
,!% 
 int !  
   int  
 
 

  

 !
     

  6 
  ! 
   

       +
 ,!%  !
   
 int  "[I"
  !
  .! 
 
 byte  "[[[B"    !
  
.
! 
 
 Object  "[[Ljava.lang.Object"    
  ! 

 

  @%$+ $

.! 
   
  "
 ! 

 int%

 ,!% 
     
 ! 
 
    
 

! 

int 
  + .5

artima.com/insidejvm/ed2/jvmP.html 22/46
11/18/2010 Java Virtual Machine's Internal Archite…

 ) *!" !! 

!

  %% 

! 
  
 D   
 %! 
!  
 !     % 
     !   , 7  

!
 
,8% 
 
 !
 Object%



#
!
 
-
  
!
 %

!
 %
  

 ;%
 

 
 
  returnAddress ",!
%
 

  
 , " $$  
 


 
!   
!

   ,  !
%

   

0
&   %!  

" ! 
 %    
       !    
! 

!



0) 
 !

artima.com/insidejvm/ed2/jvmP.html 23/46
11/18/2010 Java Virtual Machine's Internal Archite…
!
  ,

   


!
    !
   

  
          !
 
  

  %  


 



   
"  ,  !
%    !   
        

  

  &   !   


  
 

 
 
 !%
!



  !

&  
!
%!    !


   ! 


!  ! "!
,%
 !

!%
% !
!
% 


" !
  
!  
 
   !
 
!   %  

 
        
!  
    ,
%    
  

   &  !

!% 
!
 % ! 

 !
 !  !

!
 
!
  !

"  


       
     
 
   


    
 
   
 % 
   
 

 
;  !.   
 
    
  
!  &   
 
!
%!


  !
 
 
 / 
 

) 
!


Г  !


    %       ! 
  

 
!!
 +!




%



%

 
! 
! 

 
       
       
 !   

 !! 
    !! 
 ! 
 


!!
   ;
%!,!!
! !!;

0+!
 ! )
%
  %  !  ;


 
 %! 
% 
 

 !
 ;! 
!!    

!
 ;
 !!! 
  

&  !  


!
%  
! 
!

 6  !
    
  
      
 !

;
!
 



Г


 
 

   ! 
 ;  ;
. 
 


 
!


  , 
;
.
  
  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 , " 


.  2. long double   ,

 
  

   !
 !   
  
! 
! 

 % 
  + .
4





 
!
)

// 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;
}
}

 + , ! "-

=
  + .4 
    !    
 

runInstanceMethod()
  reference%  

 !  


  this  
  !
   !

  
  

:
 
 "

artima.com/insidejvm/ed2/jvmP.html 25/46
11/18/2010 Java Virtual Machine's Internal Archite…
 

 

 runClassMethod() + .4%!



  this !

 


: (
 
     
!   !
%   
    
  
!
 


=

  byte% short% char%  boolean    
 
 
! int   

  

 
  "! 
 % boolean 

 
      !     
!   int 

  boolean  




   2 byte% short%  
char% 
% 
     !      

 
     
  ! %
    !
      &
 



 %
%
 byte%short%  char

 
 int !  int
 !% 

 
byte%short%
char 
 

!


"

 Object o  
 runClassMethod()  % 
:
      " 
:  

  % 
       !
 

: 


 %

:  

" 
!!
!%
!! 

 
   

 
%  
!      
     

! !

 
  
%  
! 
!
 

 +
,!% 

!



%i  j
  Example3b%
! 

! 

 2   
 !
%
 j 
!
 

% ;


i 2 
 
!
% 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 
   
  
 
 
  !! 

;
@?
%
,!%

 


 



 %   

/ 0

Г
%
 
 ; 

  

%       % 
         

        
  

 
  %   
 

 

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
 !


 

/ 
!
 %  
%
!  
      !   .    .
   
  
  
! 
      
! 

 

  
!
%!!

 


7   
8 
!%
 
!
 

 
!  
! 

 
%
%
 

!  
 
    



!
 %

!%  +
,!% iadd 

 
    
  
 int
  

 
  %   !%  
  int   F 
   !  
  

  

 int 
int 
)

iload_0 // push the int in local variable 0


iload_1 // push the int in local variable 1
iadd // pop two ints, add them, push result
istore_2 // pop int, store into local variable 2

 6 

%   
 
% iload_0  iload_1%  int

 


;
 



   iadd 




 int %  !%    int  


    

  
% istore_2% 
  
  
  

 
    

 
 



 + .9C%
   

 

  
   
    ,    
    %
 


 
   

artima.com/insidejvm/ed2/jvmP.html 27/46
11/18/2010 Java Virtual Machine's Internal Archite…


. /0"

+!2




 
 % ! 



 



%
!!
 % ,
 
 

 


 !

  
 !  
 
  
 


0
!  
! 
  
 int% long% float% double%
 String

!
 




  0
! 

 

 
 

 
  
   %  
 %
 !
 
  
  /  

! 
:  

   

 

 

& !  


  
 
 
   

 

% !
 
 
 



!
"
! 
 %    
 % %   !
    
  

   
!
 & ! 


 

  


%  %
%
!
%  !!
  
%! !

  !

" 
!
 



% !!!  
 

!
  !
 
!
   !
 
!
! 7   8% 
artima.com/insidejvm/ed2/jvmP.html 28/46
11/18/2010 Java Virtual Machine's Internal Archite…
! !
 !
 
 !
  !


  
   
     
  !
 

   
   
 

!  !
    
!  !
    %   !  ! 



 
 
 !


 !!

 
! 
  
!
,
%
 ! 

  ,

   

,


!
  "  ,
 %          9A% $-,
%$   
    

  !
  
     -    
,
    


  
%
 , 

 

,
 %  






& !

 ,
%! ,
 

  !  


 !  
 
    ,
    !    
!  !
,
%  


  

   !  
    !  % !
 
!
    !    
!
    !  
 
   
 
!
 !   
!,
 
,
 
 !


 
 
  
 
 
  

 

%
! !
  %   ,

% !!
 

!
!! 
  %


 

#
 !! 

0

!! 
     "! 

%

  
 !!   
   !  
! 
 " ,!

%


 )

// 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;
}
}

+ .99 
   

   
     
 
addAndPrint()!
   !! 

 !    
% !
  
!  
 
  addTwoTypes() !
%
addAndPrint()!
  int
 double55 55


   
  
addTwoTypes()!


artima.com/insidejvm/ed2/jvmP.html 29/46
11/18/2010 Java Virtual Machine's Internal Archite…



/ !

  
 
  
 addTwoTypes()   
  
  

      


! 

  


  

=
  addAndPrint() !
   
 

 
     addTwoTypes()
!
%  
  
 !  Г   
   !



%  
   !

   !
  !




 
 
  

   
  
 
!
    !
  
 
addTwoTypes() !
    !    
!
 
 !   ;
6addTwoTypes()

 
     
0  javac 
! 
!  23 9 9% addTwoTypes() 6  
    

 
 
 
   7"! 
% ;
 !


  !! 
    8   !  
 
 !!

 
addTwoTypes() ! 
!       
 double  int ! 755 55  

8 
!addAndPrint()
  ! 
addTwoType()



 ;

& addTwoTypes() %  double 7 %54 558





  ! 
!
  !


!
   
  !
% addAndPrint()     double   


addAndPrint()
   !!

 addTwoType() !  

artima.com/insidejvm/ed2/jvmP.html 30/46
11/18/2010 Java Virtual Machine's Internal Archite…
!addAndPrint() !  
 , addAndPrint()!

  
addTwoType()!
 


+ .91 
  

   
      !  !! 

,   ! !
  
 
   !  
!  % 
!! 
 
 ! 
!  

    
 
 
!! 


 !
: !
 


 
 !


    
   ! 
   
 !
 
!  
 
 
 !
 
     ,!% addAndPrint()  
  

!addTwoType() 



 /-


 !!
 !!!
   !



  !       
 !
 
   !    !
! 
 
 !
 ! 
!

 !



=

 
  !$
$
 "

!
; 

!!
!! 

+ .91%

!
!!  7"! 
% !


  

%

  $
$




!
 8 


7



8
 


  ! % 


  

artima.com/insidejvm/ed2/jvmP.html 31/46
11/18/2010 Java Virtual Machine's Internal Archite…
      

  

         ! 
  

%
$ 

 $ 
 


 
  
!

/ 

 

 !!      
 
 


    + .99   + .91  "   !  !! 
   
 
 
 

 !!
 
!           !!
%  
!    
  ! 

    + .91   




!!
% !   

 
 

!!


!          ! 
 
    + .99 
 
 
 
 !
 !  
  
!
 !  
  &   % 
 

!!



=
0
 
 
    !          !   
  
 
%      
 ! 
    


 !
  &     
   !
%      
    
  

 ! 

 ! 
!  "
!
     ! 
  ! 7   

 !
  8% 

     ! 


%
!!

  !
 %
  


=!
   !! 
     !! 
   

  ! !    


     
   
 
!! 

 
 !


"  !
  
! 
 !
 &  

!
%!   ! 

 & 
  
   !
% 
%          

    !

    %    !   !
 ! 
  
 !
 / 
 

 !    ! ,       
         
! !! 
: 
7 !  8!
  %

  
!

  !! 
 !
    .  !
%    !

 & 
! 
  
%
  
 ! 
   
 

    
    

 
   
   



 
!
 !! 

" !
  7
 %
 
8

 
 !   
!
   % 
!
  


+ .9<


 
 !

 
! 
 

!
  
 

    ,      !   "  !       !
, !
%
  !
 /%!:! 


artima.com/insidejvm/ed2/jvmP.html 32/46
11/18/2010 Java Virtual Machine's Internal Archite…
   !



  -  - 

" + .9<%  



!
%

 

 !
 ! 
 !
   %
 !

   !
 


!!
 "!
         .   
  
       
   
   .   
% 
 !
% 


.   
  
 .   
  
   !
 
  
!
     !
 
 
 !
%   !


   

"  


  ! !!
 % !!
 
   !
 

 
  , ;     ,    
        

!! 
!


!!
    ;
!
%
!,!!
! !!;

-,
-  
"

 ! !! 
,
    
!  
% 

 ,
       !
   

 +
  
%  
       !! 
 
 

    
    
   , 
%     
   "
artima.com/insidejvm/ed2/jvmP.html 33/46
11/18/2010 Java Virtual Machine's Internal Archite…
! 
   
 % !! 
     
  
 
!! 
  , 
   !! 
    % :. .!

!% ,    
%   
! 

 %
 !  
!   
 6

0!
   
 !$ ! $    

%  ! $,
   $   
      
   )   
 
%
!! 
%
 !    
  
 

   ,
      !
   
   
 !! 
%
!
 6%
%%

! 


 "
 !  
 ,
  

-
  
   
! ,

    +
!    
   ! 
  %     ,  


!
 "!,
%  
,  

%
 %  :.  .!
!    ,     
 " 
! !! 
!
 
  
%
    
!  

 0  
  $  $
 
!! 
,
    " 

   
%
%
,
   

 
0

" !
 
 !   6 
  

    !   -
 



. 

;

!
 
 

 


 
  
!  /   , 
!
     
! 

!

 

 

  


  

 
 %   
! 
  7   8      
!  


 % 



 

 2  



%! ! 

 
 

7
 

8
 

 &  ,  
%! !
   
 

%    !


%
 



  !
 

,
   , 

 
! 

 
   7,
      8
  
       
!  " ,
    

 % 


 % 

    ,  
 6  

   
 %   



  -,

 
 
      
!     

! !


 
 ,

+
! ! 
 !%  ,
    !  
     
  6  
!
 

/ 

%,
   !
 

 !
  &    !
   7  
!
!%
  
  
,
8%  ,
     
  ,   ,  
    

!

/   
 
  !
%
%   
!!.
!;, 
 
 
!  
    
6  


 !
%
 ,
     
   !
  >     !
  
  
artima.com/insidejvm/ed2/jvmP.html 34/46
11/18/2010 Java Virtual Machine's Internal Archite…
 !  ,   
 &    !
  %   ! 
!

 
  ,  
    !
 
!  7 
  
,
8%! 

!
 ,

  
 

 ,

#
  :

 ,     
  !    ,  
 
 ,  "
,
  !  ,


  

 +
!  
%
 ,

 
 , 

   

   
 %    %   

 !  +
 
!  
%   goto
 return%  ,
   
!   ,

  
  ,

     
     


 ,
%,
  !  ,


  




0  
   
 ,
   athrow  
%
 ,!% 
 
,
,   

!
!
 throw!   


 -!athrow 
,%
 ,
/ 


,

   

  
   +
,!%   
! 
%
 %
!! 

!  
;
%   
   ArithmeticException    
  ,   


 
..idiv% ldiv% irem%   lrem.. 
! 

  ! 

int
long

-


 !   
! !
  
!   % !
  
        ! !



7

8
 

+
  ,!
 !

 !  ! !
%
  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 Java Virtual Machine's Internal Archite…
5 iload_0 // 1a
6 iconst_2 // 05
7 imul // 68
8 istore_0 // 3b
9 goto 2 // a7 ff f9


  ! !
!


 javap
!
0 
1 023  javap 

 
 

 
 ! !

 !

  
 =
 :!   
 
!   
 !
   goto
 
    !  
 :! 
   
 
 
 7  iinc8  

  !!  
, 
%! 

  
    
 
         
  iinc
 
 
 
 
 !  ! !
  
 % 
 
 :!
 
 
    
    
   $goto -7%$
! !
%$goto 2 $

  

    !   
   
     
 


 
 "
! 

 
 
   %  !
   
 
   
 
    
 %    %   
      
 
 , =%
 iinc 
% ! 
%

 
!!


 
 

+
,!%



%! !



% 
! 
%    
    
 
   
!
 

 ! 

:  

%! ! 


% 
 

 
 ! 

: 


 
%! !


 +%
!   
  
 

 %   
 
      
 
! 

: 


0 
..
! 
 ..   
    !   
 
 
    !  
    # 
  

   !


  )
!   % 
!
% 

 
!    
  !:
       
   
  
 
  .  
%  
%  
 
  .
  
 
     !! 

   
 
%    5CH5@   
   
.. .   ..
!
!! ! 




"
!


.  

!.
  
     ! 
!
!
  
! 
! 
 
 I
!;  % ! !
B= H .o
& 

.obj  !    
!%       ! 
!
!
  

!    
 %   !    7 !8    !  

!;  . 
  !  
  

!;
 ! 
!  .! 
: 
 ,
   

!:. .!
! 

!;

" ! 
    ?% $=
 
%$
 !:
   

   

!   
!   !
       !

  

artima.com/insidejvm/ed2/jvmP.html 36/46
11/18/2010 Java Virtual Machine's Internal Archite…

 
   

   %  
..,
  
:! .. 

   
 !


 !
 






   
 
! 

 

 
! 
!     
!     
!   ! 
!! 
%  
 ,  
   
%   .

 !
  
!;
  
 !
 
!   "
%  
!  !
 


!!! 
  
! 
.  

.  7" !! 

 
!%
 


 
!
  
!
 
.    
 

!
 ,
   
!! 




!  8

"
 
     
   
     
 
 

 
%
 
 ;  
 

 !
 
 
 ;



%    
,% ,

/   
 !      
  !


  



+
,!% 
 ! 
 


 
!
 
 
 
%!  

/  
%
istore%
 
 int 
 
%fstore%
 
float 


 

!,!  
 ,)

 

2     
    
    int   float  !
 
 
 
 



+
!   
%!  

  

 



 
 
! 

 +
 ,!%    !  
 
 

 


% 
.
 / 

int%

float    
 
  
%

! 

! 
 
 
 !

"  




  dup 
%
,!%




 0
! 
% goto%



!:

 
%
%

  ! !

!


 $$  
           ,   
! !
   .1 
   ,
  
   "   
%  
arraylength
 instanceof% 
     ,    

  
arraylength

6        instanceof

 6  
:
  

! 1 2! !


byte b baload 
byte 
!
short s saload 
short 
!
int i iaload 
int 
!
long l 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

 
 

!


 .<
 
!
  

 
 
    
!  "% 
 !  
 

    
  

 
  
      
 
  "
   !   
 !

,34! 5 
$ ! 1! !
, / $-
byte 5 int 9
short 9@ int 9
int <1 int 9
long @? long 1
char 9@ int 9
float <1 float 9
double @? double 1
reference <1 reference 9

"  $! !  

artima.com/insidejvm/ed2/jvmP.html 38/46
11/18/2010 Java Virtual Machine's Internal Archite…
!! 

  ! !  
!   


   
 
 
         
  
  
 
  
 
%
     
! ,%
 
! 
! 

 


 
 !
 A%$Г !
 $ 
 

  9C
1C

-,
 6


,
 6 !  !! 
..  %:. .!

! % 
!;
%  ,
   
..     9%
$ 


" $! 
  
!!
,
 6
  !! 
    6 
,
 

  

! 
!  


/ 
 !
   ..   .. ,
 6  
!;
 

!;
  6%      ,    ! 
!! 
%    0  F

  ! % 

 
!  6  
!  !! 
 
   

 !
0
. 
 
!%
!!

 


 ,
%   ,   
   %    !
  % 

 ,  "
!;%   

!
 
 
 .!%!
 
! 
 
  
!

   

!!
! 

"  
!;   !         
%   !

 
,

  
  

!   5C 
 4C  
 ! ,  9C 
 1C
 
  
   !

   
! ,
%   !    

 !
    
! $
 
$ ..  9C 
 1C  
  
  
,5C
4C 
!

& 
!; ! !
 

%
 

 
!


  
!;

  %
! ,!
  

  
!          !  
 
!   

!;  $
 
$ 7 9C
 1C  
 
8%  !   !

! 
 

!
!;



!;


! 
,5C
4C
 
! 

!;
!GG%!!


 
 !         
!  
 
%   "

!; !  


  !
!



  
 
  7 
 
 !!
 
!   
! , 8   !

!




%!  
!
 

  !



"
!
% 
!;

! 
!  
! 
  
 
!! 
  
 !
  
! 
!   "

!;  ! %    
! ! % 
 

$!
!;
$  
!;   !       

 "
! %! $
$
!
  
!
artima.com/insidejvm/ed2/jvmP.html 39/46
11/18/2010 Java Virtual Machine's Internal Archite…
$

%$9C
1C 

,5C
4C 
! " 
  

 
!!%  
!;   !  :
 
!;



!.


 !


!;

 "
!;   

 .!

!.. %
$. $
!
"
  
 2 D
%F

 !   0
% $  
 !

:.
 
  GG  (
   ! J 
   

   


 !
  

%  !
%   " K
L!  GG $=


!
 

  ! . 
 
!% 
 
  .   
!   
%  .
    ..  
 
% 

 
!% 
 !
   
!% 


:

  .! 


  
!%   6 
 !
  

  
 !% 
!  
 +% 


  !   0
%   !
    % !
  

  
  

!
!;


 

  

!;
!;

!

 !
  

 
   "  %
!;   
 
  

 !
 

 " !
 

 6 %


!; 
 
  !
  

%    
!;


!

   



 
  
!      ..  
 
    
 !
 

  
  

   
  !
     !  !
     

!; !
 
 
 
    !
 !
  
!;
   


   .!!!


 

!


   
:.
  % GG%

.
:.
   %   % 
:.
      !
   "   
!  
        GG%      
6   
 ! GG

"
!; 
!

!   


  
!! 

  
 

    
:.

     ! !
 !  ! !  
 7

!
8 !! 

      
  

%   ! ! 
  !! 

!



 
! !%


:

!
  


/ 



!
    !!

:  

!
!! 
! .! 



 

!
!! 
%;

!;




/  
!;


!
%  
  !%    
!

 
   
!  +
,!%   

!<C
!! 
!
!
 

%
  .! 
 

 !      
!;
 

artima.com/insidejvm/ed2/jvmP.html 40/46
11/18/2010 Java Virtual Machine's Internal Archite…
 



  %! !; ;

!;




   !   


       !
  ! 
 
!! 

   
   /  

     !
  

  !! 


  %  
   
% 
   
" %     !!    ! !  
   ! 
!! 
/  
  
!.


  



 ! 

  



/  

    !
     

 
  
.
!!
.

! 
  "       

  
  #

  
%  

            %    !     



 

!!

 !  

  

  

 


!#B! 

 
#B!

    
   
  Г
 
    
! #B !
 
 
%
 

  



  !!.   
   
%

 !. 7" %   !    

   
! #B !%    
   
 8 -  !
 

  
 !.%  
!  
 
 ! 
 
   


  

" ! 
    1% $#
!   %$ 
 !
 
 !. 


!
  (




!  

 !
!



 
!%


 
;

  !! 



     !  ! 
 
 


  )
: 
       
   /: 
    

!   


    
  

 





 


!
!!


  >   
     !  
    
 
%  
 wait()%notify()%  notifyAll()
!

Object +
!
%1C%$0 
;
$

    !  0 


%  

         !


 %  
%  
 
 -!   !
!!
%
 
!)  

:%
!
 

%      -    
  !!
%      

$
 
$

  Г
 !%

 % 
 

 !!

!
!!


!  


  ! 
 
. 


 !  !!
  +
,!%
  


! %
,   
!  long   double%  
!  +
 ,!%   
  
! 

artima.com/insidejvm/ed2/jvmP.html 41/46
11/18/2010 Java Virtual Machine's Internal Archite…

  
 int%   
 
;
%
 


 

 
  


%
      
!
      
      
 
 
%
%
%
 
$  $

,

  long
 double
 volatile >
         
! @?. %   !    
!
!! 
  
 
! <1.   0
  
.
 long 
 !!
%

,!% 
  
 
 <1. 

  
. 
! ! 
 long  
double !  
 
! 
 
    
 long
 double
 


"
 !! 
   
 6 
 

  
 
.

long  double
!%!  
 
!



   
.
! ! 
 long   double    ,
 
    



 !   
!   ,
     
    
!! 

 !





  
  
@?.
  
!!!
   %,
!!  +
!
 % 
%  
!! !   
  
;  
  long  
double

+ ! %   


   
.  
       !  
 !)

9  

 
!! !!


 !!
% 
1   
!
 !!
 
! !!


+
   

%         

 !!
   
 +



%
%

  
  

   
!! 
  !. 
!  ,  
%
  !! 
  
! ,  ,   
 
 !  !! 
 
   
      

 6 !

! 
!.


  !  . !



   
.   
   


) 
    
;% 
 

   !  !!
    
  &
  
;
% 
 !.

 ! ,   

 
!   !  !! 

& 
 
  
;
% 
% 
    !.  

 
 !! 

! 

=
  
  !  !! 
   6 
 
     !

    0
! !! 
 ! 

  !
       / !

%
  


0   =  %


 = %   
 
  =     
    

 !! 

! %
!


artima.com/insidejvm/ed2/jvmP.html 42/46
11/18/2010 Java Virtual Machine's Internal Archite…
 6

: 
!! 
    

 
 ! 7=  
!8  !
   
   = .
   ! 
!! 



!

!! 
    

 
 
  !
     


%
 
%= 

%= 

 


 


    
  
  
  

   !   
! %  
 
!! 
!


 
. !
  



!! 
2 



.
  !
      = %  
    
:  
  
!
 

!




 
% !
!
 

!  

    !      +
 ,!%  !
    ! 
 
!



!



 )

#  


"  
 
!
 
:
.

"
 
!

" 
Г
 
:

, 
 
:
.

Г
 

 ,

,

 !
 !
 

 

,

 ! 





 

:

2     !


    
      
!   

  


    
:   
!
   !! 


!

:
 ! 

! !!% !
   !!)

9   
: !
    
 !
%

1   
: 
        
   !
      
 !
  

     
  
: " 
   %
 !
             
 
   
! 

> 
" ! 
     
  %   !%  !  %  
  
  !  
 2  
6 

 ;  !! 
 
  $$ 
!
   ! 
 
 
 
!
 
   
      
!
    
 
!  
    
    6 , 

  
! !! 



% !! 
   
 %


 ! 
 
  !! 
 !   
 
 ;     
artima.com/insidejvm/ed2/jvmP.html 43/46
11/18/2010 Java Virtual Machine's Internal Archite…
!
! 

 
 
%  

F

,%
 !
 ;%




!%
!! %



  %
 !
     
..   
!
  !  
   

!! 
 

 ,
 
  
!

!! 

 
!   
!!! 
%! !; 

! 

 !! 
% 
   % !,!; 
!  ! 

 



!     , 


    !! 

 
 ! %  

! !
 !! 


!
  

 2    
 
        

 .! 

- )"0!

 2.>/ 
   !
       

 
!  

 
  + .9?!! 
,    
  (
      
  applets/EternalMath.html

!2.>/ 
  


239 C

 
 !
  

 doMathForever()!

 
Act%
  
 $ 
 0$

  !
 


 
 
   !% % 
  
!
  

 

%
  

 !

  !! 

   !   

   
  







 



)0%>%> % 0
 -!
0
%
! !
, 

 
  %
   
  
   iconst_0  
   ! 
   0 
%

% !  , iconst_0    ;


   
 

  
 , 

 , 06 
 0

 ,6   
          
  >

%!

 
 
, 

 
0



!

%>

 
  7  

8  
  
   
 
 % 
 
 
!  
!



 %

   
,  "
% !
 7$M$
$

M$8   


  


!

 
 
 
  7 !!

8

 

   

        
 


!

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 1

 
   imul 
 
 

ints 
!
 %!!%   istore_0 


 
 !    
 
   

  

!! i *= 2!  
!doMathForever()  
% goto% 

! 
   
  iinc  
  goto !!   for (;;) 



doMathForever()

& 
    
 0 
7
  

  
 >  
8%

  !
 
 & !  
 

%
: %
 !
 


 ,


+
  
  !
%     

!
   
   , 


 , 

F 


   
!!

/ 2.>/
 2.>/ 
   
 
 ,! 
!      jvm 
  
! 
      
      
  2.>/   
applets/EternalMath.html  


 
 
  %
   applets/JVMSimulators   applets/JVMSimulators/COM/artima/jvmsim



>
#
+
   
 !
 
!
 
    ! %   
 )

artima.com/insidejvm/ed2/jvmP.html 45/46
11/18/2010 Java Virtual Machine's Internal Archite…
http://www.artima.com/insidejvm/resources/



 N/

N# N-!N0 + 


N#
N=,

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

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

artima.com/insidejvm/ed2/jvmP.html 46/46

Das könnte Ihnen auch gefallen