Because Java is a strongly typed static language, it is not possible to generate code dynamically at execution time, which is essentially the case for static languages.
There are several benefits of dynamically generating code, as well as the advantages of weakly typed languages
1. Partial logic allows for hot updates
2. Remote call implementations are ideal for
3. Can dynamically generate extension classes, shielding complexity, on the original basis to extend the function, no damage to the source code features
Static language is not a solution to the problem, there are many solutions.
Embedded in a scripting engine language, it can compensate, and dynamic agent technology
The dynamic agent that comes with JDK is a solution
Cglib Dynamic agent Spring is used by default
Javassit can modify class at execution time
By the way, the Scala language can inherit a class during execution, and this syntax supports a lot of flexibility for many scenarios, and I believe that Java will be added later
[Weave message Frame] [Java Core Technology] Dynamic agent Introduction