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

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

问题描述

我一直听说所有新的很酷的特性都被添加到 JVM 中,其中一个很酷的特性是调用动态.我想知道它是什么以及它如何使 Java 中的反射式编程更容易或更好?

解决方案

这是一个新的 JVM 指令,它允许编译器生成代码,这些代码调用比以前可能的规范更宽松的方法——如果你知道什么鸭子打字" 是,invokedynamic 基本上允许鸭子打字.作为 Java 程序员,您能用它做的事情并不多;但是,如果您是工具创建者,则可以使用它来构建更灵活、更高效的基于 JVM 的语言.这里是一篇非常棒的博文,提供了很多细节.>

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?

解决方案

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.

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

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