Hi there. 2
Now let's look at the lifetime offer pipe which means that we are going to look at what happens to your 3
type since the time it does access for the very first time and the time it is executed and how it can 4
be either a class or an interface. 5
But when you look at the lifetime R-Type let's look at what components of JVM we are going to discuss 6
in this chapter. 7
You may recall this illustration from our first chapter when discussing JVM. 8
So here we have a class called Halo which needs to be executed by Gibeon. 9
And in this chapter when discussing the lifetime of type we will discuss these two components classloader 10
on bytecode verifier. 11
And once we are done with lifetime type we will look at garbage collector and to an extent we will also 12
look at bytecode instructions on Witan the execution engine. 13
We only did this because the G.I. decompiler in first chapter while discussing JVM and I think that 14
discussion would suffice and if needed to support TLAs separate lesson object decompiler at some point 15
in the future. 16
But the discussion we had should suffice. 17
Now at the top we have the different runtime data areas which represent the memory that GBM is a look 18
at it. 19
So when GBM get started it gets a look at it a chunk of memory from the underlying operating system 20
on GBM splits that memory in two different areas which we can see here and we would be discussing most 21
of these some areas. 22
So that's got to be a micro texture. 23
Now let's look at life in a market like let's consider this class called us Halo and let's assume that 24
this class is being accessed for the very first time which means that it is either being run from the 25
command line or it is being accessed in some way from some other place. 26
That is we are either creating an instance of this class or accessing some variables hard matter within 27
this particular class. 28
But this class is being accessed for the very first time and in that case we need to load this class 29
into memory and JVM does that sort of holds the class and it checks that this class is well-formed or 30
not. 31
That is whether it is obeying the language introduced off giallo. 32
Now we know that that is already done by compiler. 33
Hello dark glasses generator. 34
So the question is why is it doing. 35
One more time. 36
And the reason is this glass hollowed out glass could have been downloaded from across the network and 37
it could have been compiled by a hostile compiler whose intention is to perform some malicious actions 38
on the system on which it is going to be executed. 39
So JVM is not going to trust any of the classes that are just going to execute. 40
It needs to perform this kind of a check and if it finds that it is not real fun it is going to reject 41
this class which means that it's not going to exhibit it. 42
But if the fight is well formed then it. 43
Look it's best for any of the static variables within this class undergrad also going to initialize 44
those variables but the default values which is dependent on the data type of the variables. 45
None of this Grothus access for the very first time by creating an instance of it. 46
Then on the instance variables will also be looked at that space and they would be initialized with 47
default values. 48
So the next step is to look at any reference classes. 49
No Hello non-class might be referencing other classes. 50
That is it could be accessing variables or methods in other classes or it could be creating instances 51
of other classes. 52
So in this case we are going to at all the classes that are being referenced from the US and the final 53
step is to initialize variables. 54
Earlier we created a space for static variables and we initialized them with different values. 55
So here we are going to override those default values with the actual user defined initial values which 56
are part of either the Declaration or they could be part of the static initializer gawks or instance 57
initializer groks. 58
So those are the different steps. 59
And this first step where we are loading class it is called us loading underdosed performed by this 60
component called us classloader. 61
So when classloader has to load this class called Hello Doc class it's just a class bot to see where 62
it can find this class and once it finds that class once it gets it it reports a corresponding byte 63
course into memory. 64
And after that it generates something called as a class object which is the output of the loading step 65
on class object simply has the Mattei information about this class. 66
So that information would be things like the class name which is hollow and names of any of the superclasses 67
and it would also include information like method names and so on. 68
We very briefly discuss the class object while discussing the object class in the okes chapter not duck 69
discuss object will be created only once when the corresponding class is accessed for the first time 70
. 71
So on subsequent accesses classloader will simply fits to create a class object from the memory and 72
it would use it. 73
So the output of this loading step is a class object and that would be the input for the next step. 74
It is linking unlinking has these three steps which are represented in this three boxes on the first 75
step is cardless verification. 76
Because we are simply verifying whether the input class is well-formed or not on verification as performed 77
by a component called bytecode verifier and the next step is called preparation and the third step is 78
called a resolution because we are resolving the referenced classes. 79
Note that here the classes are being loaded at runtime. 80
OK in a dynamic range. 81
Undo to that. 82
This kind of linking is called as dynamic linking because it is happening dynamically at runtime. 83
Now in some languages there is also static blinking which happens at compile time itself so it does 84
not happen at runtime so the referenced process will be copied into the final executable at compile 85
time itself on this resolution step is an optional step which means that it can happen right after the 86
preparation step. 87
Or it can happen after the next stage which is initialization where we're actually initializing redeemers 88
so it can also happen after initialization stage. 89
So the third step is the initialization step under simply initializes the variables. 90
As discussed earlier. 91
So overloaded the default values that the user define any shell about use. 92
So those are the three stages loading linking and initialization. 93
No not that when we are loading a glass it's superclasses will be loaded before the current class so 94
its superclasses can be loaded uninitialized before the current class. 95
OK so the superclass of hello will be loaded and initialized before hello. 96
As noted on wanting to know about initialization is dark and this gives the pipe as a class but if pipe 97
happens to be an interface then it will be loaded but not initialized under could be initialized only 98
if one off its tactic methods are accessed and we know that in interface's topic methods are possible 99
only from Jawa 8 onwards before July 8. 100
Interfaces cannot how static methods. 101
So that's one way in which an interface gets initialized and the second way is if it is accessed in 102
an interface but the field is initialized via a method. 103
In that case initialization is possible. 104
So that's about initialization. 105
With respect to interfaces on Finally the type will be executed. 106
So if you are accessing a particular matter then that particular matter in the class will be executed 107
. 108
So those are the three stages. 109
Loading linking on initialization under a high level overview of these stages are in the form of lessons 110
we are going to get into the details of loading and linking unfought initialization. 111
There is nothing more to discuss with regards to initialization of interfaces. 112
We are going to look at that in a very detailed way in a demo which we will be doing after looking at 113
the theory part of the lifetime of a type. 114
So once we are done with the theory part of the lifetime of our type we are going to do more detail 115
more of the total lifetime type and that's when we will also look at the initialization of interfaces 116
and that's about it. 117
Thank you