当前位置:网站首页>day6-jvm
day6-jvm
2022-07-24 06:07:00 【lonelyMangoo】
Today's summary
jvm Dark horse 108-139p
JVM
2 Bytecode instruction
javap -v xxx.class
Bytecode execution process
main Method class loading , Put it in the method area , Constant pool (class data ) Into the runtime constant pool
Small numbers are put in the bytecode instructions of the put method , Put it in the constant pool beyond the range
- x=x++ Why is it useless
Because first x Put it on the operand stack , then x++, Finally, the value of the operand stack is given to x, At this time, it's still 0.
i++ First load Since the increase again ,++i It is to increase first and then load
- cinit
The compiler is in top-down order , Code that assigns values to all static code blocks and static members , Merge into a special method ,()V
- init
Instance object .
init Method , Also in order , The construction method finally executes
- Method call
Construction method :invokespecial
private :invokespecial
final:invokespecial
public:invokevirtual( Because it is possible to rewrite )
Interface method :invokeInterface( Support polymorphism )
Static methods :invokestatic
new Method : Allocate memory to objects in the heap — After successful allocation, put the reference of the object into the operand stack — Make a copy of the elements at the top of the stack —invokespecial Execute the construction method of the top element of the stack and remove — Save the remaining one out of the stack into the local variable table
Do not call static methods through objects 、 Variable , Two useless virtual machine instructions will be generated
- The principle of polymorphism
The virtual method table will be generated in the link phase , The entry address of the virtual method table is generated
- Find the object through the object reference of stack frame China 、
- Analysis object header , Find the object's actual classsss
- class In the structure vtable, In the class loading phase, it has been generated according to the method rewrite rules
- Look up the table to get the specific address of the method
- The bytecode of the execution method
- Exception handling
There is one Exception table, monitoring try Code , Type matching after exception , See whether it is consistent or subclass exception .
Multiple catch: There are multiple in the exception table . Because there will only be one exception , So the local variable table only occupies one slot ( Save the memory of stack frame )
multi-catch: There are multiple exceptions .xxx E | xxxE | xxxE: Three different types of exception entries are the same .
- finally
take finally The code of is put in try The piece is put again catch block
except try and catch Which cannot be captured in , Will jump to the end , The type is any, To carry out , Of course, it is also copied finally Things that are

20.
try There is... In it finally Code for , Finally, it must be implemented .
So don't be finally Write in return, Because it may be swallowed abnormally

10
No, return sentence , There will be one. slot To save , And it will throw abnormal
- synchronized
How to lock and unlock in pairs ?
First a_load hold lock Object is loaded into the operand stack , Express synchronized Start
Then copy the reference and put it in the slot , to monitorenter and monitorexit To use ( Two will consume lock quote )
monitorenter Start lock quote
Before loading lock, perform monitorexit Unlock , The same goes for exceptions , Will load lock References to objects , To unlock .
3 Compile time processing
Optimization and processing during compilation : Grammatical sugar ( The compilation process automatically generates and converts some code )
- Default constructor
The default constructor will be generated ( Without writing it yourself ), Because everything is inherited from Object.
- Automatic disassembly box
int->Integer: Packing
Integer->int: Unpacking
- Generic set values
Normal erasure : After compilation, it is uniformly set to Object
When you return, you return Object: use checkcast, take object become Integer( It is equivalent to automatically doing a forced type conversion )
The information in the method body is erased , The paradigm of local variables has not been erased , But you can't get it by reflection , Only the parameters and return values of the method can be obtained through reflection
- Variable parameters
String …args -> String[] args
If parameters are not passed , The transmission is an empty String Array , instead of null value
- foreach
Array assignment can be directly int arr[] = {}, Will become int arr[] = new int[]{}
Array foreach It's actually becoming fori
list Of foreach Is the iterator used ( Realized Iterator All of them can be used )
- switch character string
Actually, it's more hash code
- Why is it more hashcode, Use again equals Comparison? ?
hashcode To improve efficiency , Reduce comparison ,equals To compare hash Conflict ,
Because most of them hashcode It's all unique .
- Why rewrite hashcode and equals?
- Used when only one value needs to be compared , For example, different objects ,id The same can be regarded as the same
equals equal ,hashcode It must be equal ,hashcode For quick comparison ,equals For absolute equality .hashcode There are conflicting situations , So further use equals Compare
- Why rewrite equals Must be given again i forehead hashcode
- If two objects are equal , be hashcode ⼀ It must be the same
- Two objects are equal , The two one. equals() ⽅ I can't go back to true
- Two objects have the same hashcode value , They don't ⼀ Must be equal
- Sum up , equals() ⽅ The law is covered , be hashCode() ⽅ Law must also be covered. This part is borrowed from :https://juejin.cn/post/7025465769307668516,
- switch enumeration
ordinal()
- enumeration
The essence is a class, Values are actually instance objects
It's a final Of cannot be inherited , Inherited the enumeration parent class ( Support the paradigm )

Constructor private
$values Put the enumerated object into the array
It's resumed today
I had a long sleep in the morning , I played ball for a while in the afternoon , Still slack .
leetcode Do it , The code says , Project deployment .
I'll also look at the interview questions tomorrow .
边栏推荐
- Signals and systems: Hilbert transform
- On the concepts of "input channel" and "output channel" in convolutional neural networks
- AD1256
- Common methods of array
- tensorflow和pytorch框架的安装以及cuda踩坑记录
- 头歌 平台作业
- Foundation of JUC concurrent programming (4) -- thread group and thread priority
- js星星打分效果
- 比较好的CV链接收藏(动态更新)
- day2-WebSocket+排序
猜你喜欢

The problem that the user name and password are automatically filled in when Google / Firefox manages the background new account

MySql与Qt连接、将数据输出到QT的窗口tableWidget详细过程。

synergy局域网实现多主机共享键鼠(amd、arm)

Installation of tensorflow and pytorch frames and CUDA pit records
![[MYCAT] MYCAT sub database and sub table](/img/a8/ebaedfa084754ef3c96f42ed78eb81.png)
[MYCAT] MYCAT sub database and sub table
![[deep learning] teach you to write](/img/c6/333b16758d79ebd77185be6e3cb38f.png)
[deep learning] teach you to write "handwritten digit recognition neural network" hand in hand, without using any framework, pure numpy
![[FatFs] migrate FatFs manually and transfer SRAM virtual USB flash disk](/img/fb/5f3d17f1f3d6e4979ece5126e2925e.png)
[FatFs] migrate FatFs manually and transfer SRAM virtual USB flash disk

Yolov5 learning summary (continuously updated)

STM32 standard peripheral Library (Standard Library) official website download method, with 2021 latest standard firmware library download link

"Statistical learning methods (2nd Edition)" Li Hang Chapter 17 latent semantic analysis LSA LSI mind mapping notes and after-school exercise answers (detailed steps) Chapter 17
随机推荐
【数据库系统原理】第四章 高级数据库模型:统一建模语言UML、对象定义语言ODL
"Statistical learning methods (2nd Edition)" Li Hang Chapter 13 introduction to unsupervised learning mind map notes
[deep learning] handwritten neural network model preservation
STM32标准外设库(标准库)官网下载方法,附带2021最新标准固件库下载链接
Watermelon book / Pumpkin book -- Chapter 1 and 2 Summary
[raspberry pie 4B] VII. Summary of remote login methods for raspberry pie xshell, putty, vncserver, xrdp
Sequential stack C language stack entry and exit traversal
Delete the weight of the head part of the classification network pre training weight and modify the weight name
Foundation of JUC concurrent programming (6) -- lock lock
PDF Text merge
Paper reading endmember guided unmixing network (EGU net)
"Statistical learning methods (2nd Edition)" Li Hang Chapter 17 latent semantic analysis LSA LSI mind mapping notes and after-school exercise answers (detailed steps) Chapter 17
餐饮数据统计分析---泰迪云课程大作业
Unicast, multicast, broadcast, tool development, introduction to QT UDP communication protocol development and source code of development tools
STM32 DSP library MDK vc5\vc6 compilation error: 256, (const float64_t *) twiddlecoeff64_ 256, armBitRevIndexTableF64_ 256,
day4-jvm
"Statistical learning methods (2nd Edition)" Li Hang Chapter 14 clustering method mind map notes and after-school exercise answers (detailed steps) K-means hierarchical clustering Chapter 14
‘Results do not correspond to current coco set‘
[activiti] personal task
UDP通讯应用于多种环境的Demo