什么是invokedynamic以及如何使用它? [英] What's invokedynamic and how do I use it?

查看:145
本文介绍了什么是invokedynamic以及如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直听说有关添加到JVM的所有新酷功能,其中一个很酷的功能是invokedynamic。我想知道它是什么以及它如何使Java中的反射编程更容易或更好?

I keep hearing about all the new cool features that are being added to the JVM and one of those cool features is invokedynamic. I would like to know what it is and how does it make reflective programming in Java easier or better?

推荐答案

这是一个新的允许编译器生成代码的JVM指令,该代码调用具有比以前更宽松的规范的方法 - 如果你知道什么是 duck typing 是的,invokedynamic基本上允许鸭子打字。作为Java程序员可以用它做的事情并不多;但是,如果您是工具创建者,则可以使用它来构建更灵活,更高效的基于JVM的语言。 此处是一篇非常精彩的博客文章,提供了大量细节。

It is a new JVM instruction which allows a compiler to generate code which calls methods with a looser specification than was previously possible -- if you know what "duck typing" is, invokedynamic basically allows for duck typing. There's not too much you as a Java programmer can do with it; if you're a tool creator, though, you can use it to build more flexible, more efficient JVM-based languages. Here is a really sweet blog post that gives a lot of detail.

这篇关于什么是invokedynamic以及如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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