1

00:00:07,350  -->  00:00:09,840
Hi there this is they don't want to know.

2

00:00:09,860  -->  00:00:11,430
And welcome back.

3

00:00:11,430  -->  00:00:17,040
It's not time to learn about the under the hood the days or the way the movie industry folks call it

4

00:00:17,460  -->  00:00:19,610
behind the scenes didas.

5

00:00:19,740  -->  00:00:23,090
So we're going to learn about what goes on within JVM.

6

00:00:23,340  -->  00:00:29,880
And to be a complete engineer that's very important to a lot of programmers even though they have been

7

00:00:29,880  -->  00:00:31,540
programming for years.

8

00:00:31,710  -->  00:00:35,120
Do not have enough understanding of how JVM works.

9

00:00:35,310  -->  00:00:40,890
It is relatively rare for Djala courses or even giallo books to cover this topic.

10

00:00:41,250  -->  00:00:44,950
So it's a special chapter and I hope you like it.

11

00:00:46,020  -->  00:00:49,680
Let's just briefly review the control in this program.

12

00:00:49,680  -->  00:00:55,360
It would serve as a motivation for investing over time in learning about JVM internals.

13

00:00:55,800  -->  00:01:01,650
So here we have three courses class initialization D-Mont. subclass and superclass subclasses extending

14

00:01:01,740  -->  00:01:07,560
extending the superclass and class initialization is just an independent class which is run from the

15

00:01:07,560  -->  00:01:08,340
command line.

16

00:01:08,360  -->  00:01:10,750
And so it has a main method here.

17

00:01:10,770  -->  00:01:11,850
But we will not do that.

18

00:01:11,850  -->  00:01:16,440
The more I know the more will be done later but we'll just look at the concurrent floor right here within

19

00:01:16,440  -->  00:01:17,370
this slide.

20

00:01:17,950  -->  00:01:24,800
And it has a static initializer block and an instance initializer Rob or here on both of them Halprin

21

00:01:24,870  -->  00:01:28,040
statements saying where we are within the program.

22

00:01:28,080  -->  00:01:32,640
Here we are saying that we are inside the static initializers block within the class initialization

23

00:01:32,650  -->  00:01:38,330
Demel and within the subclass There is also the static initial as a Glock undercharge or defining.

24

00:01:38,490  -->  00:01:41,670
You'll start to underscore final Antarctic underscore final two.

25

00:01:41,790  -->  00:01:47,670
So both of them are static final views on one of them as a compile time constant whereas the other one

26

00:01:47,670  -->  00:01:51,330
is initialized via a random function within the math class.

27

00:01:51,760  -->  00:01:54,130
And here we have the main function.

28

00:01:54,190  -->  00:02:01,200
Also the boot subgraphs on superclass have constructors here with respect to print statements and within

29

00:02:01,200  -->  00:02:06,530
the main statement we have these two print statements both of them are printing these statements that

30

00:02:06,790  -->  00:02:10,650
not to underscore final so they are just accessing the static underscore final.

31

00:02:10,660  -->  00:02:14,750
Unstarted underscored final two undervalues are getting rendered here.

32

00:02:14,790  -->  00:02:18,450
And finally we are creating an instance of the subclass.

33

00:02:18,450  -->  00:02:21,840
Now when we run this class class initialization DeMaio.

34

00:02:21,900  -->  00:02:26,370
So there are these put in statements that get printed because most of them aren't.

35

00:02:26,370  -->  00:02:31,220
The interesting thing would be to observe the order in which these print statements get printed.

36

00:02:31,230  -->  00:02:32,860
So that would be the interesting thing.

37

00:02:32,910  -->  00:02:39,660
And from that we can look at couple of questions and that word so as motivation for why we are going

38

00:02:39,660  -->  00:02:43,840
to spend some time on this chapter learning the GBM internals.

39

00:02:44,610  -->  00:02:50,190
So let's assume that we have run this program using the Java command and the first statement that gets

40

00:02:50,190  -->  00:02:50,860
executed.

41

00:02:50,920  -->  00:02:55,570
So the print statement within the static initializer block is getting executed.

42

00:02:56,040  -->  00:02:58,150
Next is the print statement.

43

00:02:58,200  -->  00:03:03,840
The statement in the main method is getting a good or so the instance initializer is not getting executed

44

00:03:03,890  -->  00:03:04,060
.

45

00:03:04,190  -->  00:03:09,120
OK so that's one question that we can have raised or not getting printer.

46

00:03:09,270  -->  00:03:14,430
And the third statement is actually the static initializer group within subclass is getting initialiser

47

00:03:14,910  -->  00:03:16,570
is getting executed.

48

00:03:16,620  -->  00:03:21,410
So this print statement is getting executed rather than the second statement in the main method.

49

00:03:21,420  -->  00:03:26,610
So that's another question why is this thing getting is why is this thing getting printed.

50

00:03:26,940  -->  00:03:30,690
And then the second statement is getting executed.

51

00:03:30,840  -->  00:03:32,940
So so that's the question.

52

00:03:33,000  -->  00:03:39,120
Another question is what exactly is happening with the subclass itself when it is being accessed here

53

00:03:39,120  -->  00:03:42,660
when we are accessing the static final fields in the subclass.

54

00:03:42,750  -->  00:03:46,230
What is going to happen to subclass behind the scenes.

55

00:03:46,230  -->  00:03:52,470
So that's another question and the next treatment would be the superclass constructor would get executed

56

00:03:52,650  -->  00:03:55,310
and then the sapless constructor would get executed.

57

00:03:55,740  -->  00:03:59,690
So these are the kind of questions that this chapter will help us answer.

58

00:03:59,790  -->  00:04:06,720
And next we will do will cover something called as lifetime offer type and once we do that we will clearly

59

00:04:06,720  -->  00:04:08,740
understand what is happening here.

60

00:04:08,970  -->  00:04:12,500
So we will revisit this program later after completing that topic.

61

00:04:12,510  -->  00:04:17,430
The lifetime offer on a duck pond or family will be a real I'm offered.

62

00:04:17,430  -->  00:04:19,870
So next let's look at the agenda.

63

00:04:20,120  -->  00:04:24,270
We will first understand the lifetime of type within Gibeon.

64

00:04:24,450  -->  00:04:29,840
That is a lifetime book classes and interfaces within GBM.

65

00:04:29,910  -->  00:04:35,850
Next we will look at runtime data areas which will help us understand the different memory areas within

66

00:04:35,850  -->  00:04:41,720
GBM and how pipes and objects are handled within these memory areas.

67

00:04:41,730  -->  00:04:48,150
Finally we will look at the anatomy of a Djala classified which would help us understand a Java program

68

00:04:48,270  -->  00:04:49,890
at bytecode level.

69

00:04:49,890  -->  00:04:52,470
That is how Reems instructions work.

70

00:04:52,470  -->  00:04:56,570
So that's the agenda that we have for this chapter.

71

00:04:57,150  -->  00:05:03,420
Before we get started with GBM internals let's just do a very brief recap of what we discussed about

72

00:05:03,420  -->  00:05:09,490
GBM in the first chapter GBM is a cornerstone of Jalopnik foam.

73

00:05:09,600  -->  00:05:15,630
It hurts Djala it use some of its goals like platform independence security and very fast execution

74

00:05:15,630  -->  00:05:16,370
.

75

00:05:16,380  -->  00:05:22,200
It's an incredibly bright Thisted and very optimized runtime environment with excellent concurrency

76

00:05:22,200  -->  00:05:22,870
support.

77

00:05:23,190  -->  00:05:26,560
But just critical and overlapping large scale systems.

78

00:05:26,640  -->  00:05:33,780
Sometimes people say that even if joggles Abi GBM would still remain as JVM can't support many other

79

00:05:33,810  -->  00:05:40,290
popular languages like Scarlet groovey and closure that is source code in these other languages can

80

00:05:40,290  -->  00:05:48,570
be compiled into Java bytecode which can be run on JVM java what your mission is Calder's virtual because

81

00:05:48,570  -->  00:05:53,190
it's an abstract computing machine that is like a real computing machine.

82

00:05:53,220  -->  00:05:58,190
It has an instruction set that it executes which we know is a job by code.

83

00:05:58,580  -->  00:06:05,850
So for a Sebille machine code so says the instruction set well for a JVM Java bytecode so says the instruction

84

00:06:05,850  -->  00:06:06,710
set.

85

00:06:07,170  -->  00:06:12,180
Like a real computing machine GBM also Manipal its memory at runtime.

86

00:06:12,450  -->  00:06:17,340
That is it uses memory to run its programs and to manipulate their data.

87

00:06:18,250  -->  00:06:25,290
JVM has few core responsibilities and they include loading and interpreting of Java bytecode security

88

00:06:25,550  -->  00:06:28,070
an automatic memory management.

89

00:06:29,060  -->  00:06:35,010
Now this slide demonstrates the platform independence capability of Jawa platform independence is possible

90

00:06:35,010  -->  00:06:41,330
because JVM is platform dependent which can execute the platform independent job bytecode.

91

00:06:41,910  -->  00:06:45,150
This whole process is pretty similar to interpretation.

92

00:06:45,180  -->  00:06:49,510
It is just a JVM interprets bytecode and sort of source code.

93

00:06:50,460  -->  00:06:56,780
When we discuss JVM there are three things but Ingrid Hostetter a GBM specification.

94

00:06:56,850  -->  00:07:02,340
It is simply a specification that describes JVM features on how it should work.

95

00:07:02,340  -->  00:07:04,570
It also specifies the instruction set.

96

00:07:05,040  -->  00:07:12,720
Anyone can use a specification to implement their own Gibeon nesting related or JVM is a concrete implementation

97

00:07:12,720  -->  00:07:20,190
of the JVM specification popular JVM implementations include Oracle's hotspot and IBM GBM.

98

00:07:20,550  -->  00:07:26,910
Finally the third notion pertaining any good JVM is a runtime instance which is simply an instance of

99

00:07:26,910  -->  00:07:29,260
a concrete JVM implementation.

100

00:07:29,760  -->  00:07:35,640
When we're on a Java program from command line at runtime instance of JVM is created and then loaded

101

00:07:35,640  -->  00:07:39,700
into memory before that program can be run.

102

00:07:39,810  -->  00:07:46,110
Finally with regards to performance JVM plays a critical role in ensuring that Djala programs run very

103

00:07:46,110  -->  00:07:47,730
fast.

104

00:07:47,730  -->  00:07:54,240
One reason is to do with job bytecode as interpreting Java bytecode is much faster than interpreting

105

00:07:54,240  -->  00:07:55,390
source code.

106

00:07:55,800  -->  00:08:01,540
This is because bytecode has a compact format and is already compiled and optimized.

107

00:08:02,100  -->  00:08:08,700
Additionally most JVM implementations also perform just in time or GRB compilation to further speed

108

00:08:08,700  -->  00:08:16,570
up execution Geddie compiler basically caches frequently use bytecode in the form of machine code on

109

00:08:16,620  -->  00:08:17,430
when needed.

110

00:08:17,530  -->  00:08:17,930
Good stuff.

111

00:08:17,950  -->  00:08:21,310
Gosh the machine code to speed up performance.

112

00:08:21,810  -->  00:08:27,510
So that's a quick recap I and it's time to get started now on learning about JVM maintenance
