Architecture
Dynamic invocation is built on the fact that, even if Java is a strongly static language at the language level, the type information is much less prevalent at the bytecode level.
However, dynamic languages implementations need to be able to use just-in-time compilation (rather than reflection) to achieve a good performance, and so to compile scripts to bytecode at runtime. To be allowed to be run by the Java Virtual Machine, these bytecodes must be verified prior to the execution, and the verifier check that the types are static throughout the code. It leads to these implementations having to create many different bytecodes for the different contexts of a method call, each time the signature of the arguments change.
This not only uses a lot of memory, but also fills a memory area called Permanent Generation, a part of the heap used by the JVM to store information about classes. Memory used in this area is never garbage collected because it stores immutable data in the context of Java programs; and because of that, dynamic languages implementations can only compile a small part of the scripts.
JSR 292 proposes to:
- provide a mechanism whereby an existing class can be loaded and modified, producing a new class with those modifications but sharing the rest of its structure and data, thus not filling the Permanent Generation space,
- provide the new
invokedynamicbytecode which allows the JVM to optimize these kind of calls.
Read more about this topic: Da Vinci Machine
Famous quotes containing the word architecture:
“Poetry is not only dream and vision; it is the skeleton architecture of our lives. It lays the foundations for a future of change, a bridge across our fears of what has never been before.”
—Audre Lorde (19341992)
“Art is a jealous mistress, and, if a man have a genius for painting, poetry, music, architecture or philosophy, he makes a bad husband and an ill provider.”
—Ralph Waldo Emerson (18031882)
“No architecture is so haughty as that which is simple.”
—John Ruskin (18191900)