且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从JDK7中的源代码调用InvokeDynamic

更新时间:2021-12-23 01:00:27

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)