Saturday, 19 October 2019

How JVM Works – JVM Architecture

How JVM Works – JVM Architecture?


JVM - run time engine for your java applications.JVM is the one that actually calls the main method present in a java code. JVM is part of your java run time environment.

When we compile a .java file, .class files(contains byte-code) with the same class names present in .java file are generated by the Java compiler. This .class file goes into various steps when we run it. These steps together describe the whole JVM.

jvm
Class Loader:
mainly having 3 activities

  • Loading
  • Linking
  • Initialization
⇛ Loading

in Loading class loader reads .class file and genrate corresponding binary data and save it in the method area.
for each .class file jvm stores following information in method area:
  • Fully qualified name of the loaded class and its immediate parent class.
  • Whether .class file is related to Class or Interface or Enum
  • Modifier, Variables and Method information etc.
After loading .class file, JVM creates an object of type Class to represent this file in the heap memory

Note-
Please note that this object is of type Class predefined in java.lang package. This Class object can be used by the programmer for getting class level information like name of class, parent name, methods and variable information etc.

To get this object reference we can use getClass() method of Object class.

Note : For every loaded .class file, only one object of Class is created.

Linking : Performs verification, preparation, and (optionally) resolution.






No comments:

Post a Comment

Note: only a member of this blog may post a comment.