java - Java7中方法句柄的用途是什么?

标签 java

<分区>

我看到在 Java7 命名方法处理程序中添加了一个新东西。它们适用于什么场景?

最佳答案

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.

关于java - Java7中方法句柄的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11716133/

相关文章:

java - 在 Java 中用 1..N 坐标表示玩家

java - Map.keySet() 和 Set.addAll 抛出 NullPoniterException

java - 使用 selenium 在 IE 中处理刷新警报

java - "this()"方法是什么意思?

java - 我可以更新 ApplicationModule 并在每次注入(inject)时获取更新的值吗

java - 崩溃正在尝试寻找视野

java - BoneCP 和 hibernate

java - ElasticSearch 轮询不起作用

java - Android java循环遍历对象列表

java - 如何在 Maven 的本地项目中安装依赖项?