Thursday, August 26, 2010

JDK 7 Feature: Support for Dynamically Typed Languages in the Java Virtual Machine

JDK 7: support for dynamically typed languages in the Java virtual machine (JVM). This feature, which implements JSR 292: Supporting Dynamically Typed Languages on the Java Platform, is the logical follow-on to JSR 223: Scripting for the Java Platform. Support for JSR 223 was provided as part of Java SE 6 and implemented in JDK 6.

With the addition of support for JSR 292 in JDK 7, dynamically typed languages should run faster in the JVM than they do today. A key part of this support is the addition of a new Java bytecode, invokedynamic, for method invocation, and an accompanying linkage mechanism that involves a new construct called a method handle. These features enable implementers of compilers for dynamically typed languages, that is, the people who develop compilers for languages such as JRuby and Jython, to generate bytecode that runs extremely fast in the JVM.

This should increase the variety and quality of dynamically typed languages that run in the JVM. Application developers should see more of their favorite dynamically typed languages available in the Java ecosystem. Also, these features should boost the performance of code generated by dynamically typed language compilers that already run in the JVM. For example, the JRuby compiler generates bytecode that performs well in the JVM, but the JRuby bytecode will run even faster when the JRuby compiler is modified to use the invokedynamic bytecode and method handles.

The JSR 292 Expert Group is also investigating support for interface injection, the ability to modify classes at runtime so that they can implement new interfaces -- this is a feature that is common in dynamically typed languages.

No comments:

Post a Comment