Вы находитесь на странице: 1из 14

java

Javaisaprogramminglanguageoriginallydeveloped
byJamesGoslingatSunMicrosystems.

ThelanguagederivesmuchofitssyntaxfromCandC+
+buthasasimplerobjectmodel.
Javaapplicationsaretypicallycompiledtobytecode
(classfile)thatcanrunonanyJavaVirtual
Machine(JVM)regardlessofcomputerarchitecture.

Virtualmachine
BeforeunderstandingwhatisJVMletusfirst
knowwhatvirtualmachineis.
Avirtualmachineisalayerofabstractionthat
givesaprogramonesimplifiedinterfacefor
interactingwithavarietyofphysicalcomputers
andtheiroperatingsystems.

Java virtual machine


Asthenameindicates,JVMisnotarealhardware
machinebutasoftwarelayerwhichresemblesan
hardwareplatform.
JVMconverts Javabytecodeintomachinelanguage
andexecutesit.
Thebytecodecanbeexecutedonanyplatformwhere
thereexistJVM.

JVMsareavailableformanyhardwareand
softwareplatforms.
TheuseofthesamebytecodeforallJVMsonall
platformsallowsJavatobedescribedasa"write once,
run anywhere"programminglanguage.
Thus,theJVMisacrucialcomponentoftheJava
platform.

DiagramofJVM

ComponentsofJVM
1.
2.
3.
4.
5.

Bytecodeverifier
Classloader
Executionengine
Garbagecollector
SecurityManager

Bytecodeverifier
Asthenamesuggests,bytecodeverifierisusedtoverify
thebytecode.
Bytecodeverifierchecksforunusualcode.

Classloader
Classloaderloadsjavaclassesintojavavirtualmachine.
AllJavavirtualmachinesincludeoneclassloaderthatis
embeddedinthevirtualmachine.
ThemainfeatureoftheclassloaderisthatJVM.
doesntneedtohaveanyknowledgeabouttheclasses
thatwillbeloadedatruntime.
Classloaderreadsbytecodeandcreatestheinstanceof
theclass

Executionengine
TheexecutionenginehelpsJVMtoconvertbytecodeinto
machinecode.
Ithastwoparts:
a)Interpreter
b)Just-in-time-interpreter
Note:aninterpretergeneratesandexecutesthemachinecode
instructionsontheflyforeachinstructionregardlessof
whetherithaspreviouslybeenexecuted.
whereas

AJITcachestheinstructionsthathavebeenpreviously
beeninterpretedtomachinecode,andreuses
thosenativemachinecodeinstructionthussavingtime
&resourcesbynothavingtore-interpretstatements
thathavealreadybeeninterpreted.
Executionengineisresponsibleforexecutingthe
instructionscontainedinthemethodsofloaded
classes.

Garbagecollector
Garbagecollectionistheprocessofautomaticallyfreeing
objectsthatarenolongerreferencedbytheprogram.

When an object is no longer used, the garbage collector reclaims


the underlying memory and reuses it for future object allocation.
This means there is no explicit deletion and no memory is given
back to the operating system.

Itperiodicallycheckfortheobjectonheap,whoselinkis
brokensoitcancollectgarbagefromheap.
Garbagecollectionrelievesjavaprogrammer
frommemorymanagement.

Securitymanager
Securitymanageconstantlymonitorsthecode.
Itisspecial javaobjectthatisresponsibleforguarding
securitypoliciesforjavaapplications.
Itisalwaysconsultedbeforeanypotentiallydangerous
operationisrequestedbyajavaapplication.

ComparisonofJVM
Othersoftware:

JVM:

Вам также может понравиться