InvokeDynamic from source code in JDK7

跟風遠走 提交于 2019-11-30 09:51:43

问题


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

See here: http://fwierzbicki.blogspot.com/2009/08/invokedynamic-and-jython-part-i.html

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


回答1:


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

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

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)



来源:https://stackoverflow.com/questions/7031634/invokedynamic-from-source-code-in-jdk7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!