My question is I modify the java code, and then the page requests execution, and the server automatically compiles it into bytecode and sends it to the jvm for running. Why do we need to restart the jvm to execute the modified code?
The essence of hot deployment is to replace the class, which means that the old class needs to be kicked out of the memory and the new class reloaded. This involves unloading the class, and one of the conditions for unloading a class is that its ClassLoader can Picked up by the garbage collection. On the other hand, if the ClassLoader cannot be recycled, then java can only be restarted.
Java has many hot deployment solutions. https://www.google.com/search...
But hot deployment will affect performance, and in a production environment, the frequency of Java code deployment is very low.
So, hot deployment is generally enabled in the development environment.
Frequent compilation of virtual machines will occupy Jvm running memory, affect GC, and website performance will be reduced
The essence of hot deployment is to replace the class, which means that the old class needs to be kicked out of the memory and the new class reloaded. This involves unloading the class, and one of the conditions for unloading a class is that its ClassLoader can Picked up by the garbage collection. On the other hand, if the ClassLoader cannot be recycled, then java can only be restarted.