I see there is a new thing added up in Java7 named method handlers. For what scenario they are useful for?
http://www.oracle.com/technetwork/articles/javase/index-136358.html
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.
...
A method handle is a simple object of type java.dyn.MethodHandle that contains an anonymous reference to a JVM method. A method handle is callable just like a named reference to a method. What makes it unique, however, is that it is accessed through a pointer structure, as opposed to a linked name.
IMHO It is a tool set ahead of its time. It is intend to replace reflections but has some performance issues (it can much faster or slower, but not consistently faster) It synatx is a bit cumbersome as well.
What is coming in Java 8 is closures and first class method references. MethodHandles will play a big part in this and make their use/syntax natural and integrated. i.e. you will be able to use the new java syntax without having to refer to this class directly and the compiler will assist in the checking of types and exception throw in a way it cannot do with reflections now. I assume by the time Java 8 is release its performance issues will be resolved as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With