从JDK7中的源代码调用InvokeDynamic [英] InvokeDynamic from source code in JDK7

查看:92
本文介绍了从JDK7中的源代码调用InvokeDynamic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JDK 7的预发行版本包含一个类java.dyn.InvokeDynamic,该类允许根据源代码创建invokedynamic指令.

Prerelease versions of JDK 7 contained a class java.dyn.InvokeDynamic that allowed creating invokedynamic instructions from source code.

请参阅此处: http://fwierzbicki.blogspot.com/2009/08/invokedynamic-and-jython-part-i.html

在JDK 7官方发行版中,此类消失了.有人知道此源代码选项是否仍然受支持吗?

In the official JDK 7 release this class seems to have disappeared. Does anyone know if this source-code option is still supported?

推荐答案

java.dyn包已重命名为java.lang.invoke.

java.dyn package has been renamed to java.lang.invoke.

尽管我认为您不能从Java创建"invokedynamic"指令,但该指令可用于其他动态语言.

Though I don't think you can create the 'invokedynamic' instruction from Java, the instruction is there for other dynamic languages.

在Java中,您可以使用"java.lang.invoke.MethodHandle"作为反射的更快替代方法,MethodHandle类的javadoc中提供了示例.注意,invokedynamic指令本身依赖于MethodHandle来动态链接方法. (有关更多详细信息,您可以阅读Oracle的文章新的JDK 7功能:在Java虚拟机中支持动态类型的语言)

In Java you can use 'java.lang.invoke.MethodHandle' as a faster alternative to reflection, examples are available in the javadoc of the MethodHandle class. Note that invokedynamic instruction itself relies on MethodHandle for dynamic linking of methods. (For more details you can read Oracle's article New JDK 7 Feature: Support for Dynamically Typed Languages in the Java Virtual Machine)

这篇关于从JDK7中的源代码调用InvokeDynamic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆