Java8学习笔记(3) -- InvokeDynamic指令在Groovy里的使用

Indy 9.0.50(最后更新于2008-1-23) Indy的经典版本,Delphi 7下网络开发必备 立即下载

上一篇文章以Java8的Lambda表达式为切入点,讨论了invokedynamic(下文简称indy)指令。为了加深对indy指令的理解,本文来研究一下Groovy是如何利用indy指令的。

准备工作

虽然Groovy从2.0开始支持indy,但并非是默认启用indy的,而是需要选择适当的jar(带indy后缀),和命令行参数(-indy)。下载Groovy2.3,为了方便起见,我们使用里面的groovy-all-2.3.0-indy.jar:

创建一个文件夹,把groovy-all-2.3.0-indy.jar提取到里面。然后再在文件夹里创建一个groovy类,名为InDyTest.groovy,内容如下:

class InDyTest {
    
    def m(x, y) {
        x + y
    }
    
}
打开命令行窗口,cd到这个文件夹下,用下面的命令编译InDyTest.groovy:

java -cp groovy-all-2.3.0-indy.jar org.codehaus.groovy.tools.FileSystemCompiler -indy InDyTest.groovy
如果Java环境正确安装的话,应该能编译出InDyTest.class,然后用下面的命令反编译它:

javap -v -p InDyTest.class > InDyTest_javap.txt
到此为止,你创建的文件夹下面应该包含四个文件,如下图所示:

观察class文件

用文本编辑器打开InDyTest_javap.txt,找到m()方法,可以看到,groovyc确实为x+y这句代码(实际上是x.plus(y))生成了一条indy指令:

找到常量池#43:

根据上一篇文章的介绍,知道它表示的是像下面这样一个动态调用:

Object invoke(Object, Object) {...}
再看BootstrapMethod#0:

于是我们知道启动方法是IndyInterface.bootstrap()。

bootstrap()方法

下面是IndyInterface.bootstrap()方法的代码:

/**
* bootstrap method for method calls from Groovy compiled code with indy
* enabled. This method gets a flags parameter which uses the following
* encoding:<ul>
* <li>{@value #SAFE_NAVIGATION} is the flag value for safe navigation see {@link #SAFE_NAVIGATION}<li/>
* <li>{@value #THIS_CALL} is the flag value for a call on this see {@link #THIS_CALL}</li>
* </ul>
* @param caller - the caller
* @param callType - the type of the call
* @param type - the call site type
* @param name - the real method name
* @param flags - call flags
* @return the produced CallSite
* @since Groovy 2.1.0
*/
public static CallSite bootstrap(Lookup caller, String callType, MethodType type, String name, int flags) {
    boolean safe = (flags&SAFE_NAVIGATION)!=0;
    boolean thisCall = (flags&THIS_CALL)!=0;
    boolean spreadCall = (flags&SPREAD_CALL)!=0;
    int callID;
    if (callType.equals(CALL_TYPES.METHOD.getCallSiteName())) {
        callID = CALL_TYPES.METHOD.ordinal();
    } else if (callType.equals(CALL_TYPES.INIT.getCallSiteName())) {
        callID = CALL_TYPES.INIT.ordinal();
    } else if (callType.equals(CALL_TYPES.GET.getCallSiteName())) {
        callID = CALL_TYPES.GET.ordinal();
    } else if (callType.equals(CALL_TYPES.SET.getCallSiteName())) {
        callID = CALL_TYPES.SET.ordinal();
    } else if (callType.equals(CALL_TYPES.CAST.getCallSiteName())) {
        callID = CALL_TYPES.CAST.ordinal();
    } else {
        throw new GroovyBugError("Unknown call type: "+callType);
    }
    return realBootstrap(caller, name, callID, type, safe, thisCall, spreadCall);
}
根据class文件分析可知,当JVM调用bootstrap()方法时,传入的callType是"invoke"(==CALL_TYPES.METHOD.getCallSiteName()),name是"plus",flags是0。于是上面的方法实际上等价于:

public static CallSite bootstrap(Lookup caller, String callType, MethodType type, String name, int flags) {
    return realBootstrap(caller, "plus", CALL_TYPES.METHOD, type, false, false, false);
}

realBootstrap()方法

/** 
* backing bootstrap method with all parameters
*/
private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) {
    // since indy does not give us the runtime types
    // we produce first a dummy call site, which then changes the target to one,
    // that does the method selection including the the direct call to the
    // real method.
    MutableCallSite mc = new MutableCallSite(type);
    MethodHandle mh = makeFallBack(mc,caller.lookupClass(),name,callID,type,safe,thisCall,spreadCall);
    mc.setTarget(mh);
    return mc;
}
realBootstrap()方法比较复杂,我自己也没彻底搞清楚。初略的说,这个方法返回一个CallSite,这个CallSite的目标MethodHandle最终会调用selectMethod()方法,然后selectMethod()方法会根据caller等信息选出最合适的一个方法进行调用。
/**
* Core method for indy method selection using runtime types.
*/
public static Object selectMethod(MutableCallSite callSite, Class sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable {
    Selector selector = Selector.getSelector(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, arguments);
    selector.setCallSiteTarget();

    MethodHandle call = selector.handle.asSpreader(Object[].class, arguments.length);
    call = call.asType(MethodType.methodType(Object.class,Object[].class));
    return call.invokeExact(arguments);
}

总结

Groovy为了利用indy指令,大量使用了MethodHandle。所以,要想彻底理解indy指令,还是先彻底理解MethodHandle(以及相关的)类吧 :(

参考资料

Using Groovy to play with invokedynamic




Java中invokedynamic字节码指令问题 主要介绍了Java中invokedynamic字节码指令问题,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下 立即下载

相关推荐

09JVM是怎么实现invokedynamic的?(下)1

在第一次执行 invokedynamic 指令时,Java 虚拟机会调用该指令所对应的启动方法(BootStrapMethod),来生成前面提到的调用点,并且将

关于 Groovy Indy 选项

关于 Groovy Indy 选项

杨波的专栏 1087

电影台词预测类型:NLP小样本多标签分类实战

电影类型预测本质上是短文本语义建模问题,核心在于从高度碎片化、低语义密度的台词(平均仅12.7词)中挖掘隐含的类型学编码规则。其技术难点在于:需应对省略主语、倒装、拟声词等非规范表达;处理Drama与Comedy等类型强共现的多标签耦合;并克服领域迁移障碍——维基文本预训练模型在台词上性能骤降0.11。解决方案聚焦RoBERTa微调、类型感知注意力机制与标签平滑策略,兼顾小样本鲁棒性与业务可解释性,广泛适用于影视元数据标注、智能推荐系统及NLP教学实践。

weixin_33309048的博客 294

groovy安装配置及其开启indy、@CompileStatic

groovy测试篇 开启Indy、@CompileStatic以优化groovy的执行

DRD 4161

在Ubuntu 22.04 LTS上搞定Intel Quartus Prime 22.1和QuestaSim:一份保姆级的安装与License配置指南

本文提供在Ubuntu 22.04 LTS上安装和配置Intel Quartus Prime 22.1与QuestaSim的详细指南。涵盖依赖安装、环境变量设置、License配置及常见问题解决,帮助FPGA开发者快速搭建稳定的开发环境。特别针对Ubuntu系统优化,确保工具链高效运行。

weixin_29208077的博客 320

ANSYS Sherlock新手避坑:从ODB++文件导入到属性匹配的完整流程(附官方教程路径)

本文详细解析了ANSYS Sherlock从ODB++文件导入到属性匹配的完整流程,帮助新手避开常见陷阱。内容包括环境准备、官方教程使用技巧、ODB++导入关键检查点、属性验证策略及常见报错解决方案,特别强调了路径设置和材料匹配的重要性,提升仿真效率。

weixin_42519781的博客 460

Scripting Java #3:Groovy与invokedynamic

只需看看今天Groovy语言实现机制。在此之前,是第一个推倒静态类型与动态类型语言在实现上面的一些差异。 静态类型 vs. 动态类型 看以下这个简单的栗子。 def addtwo(a, b) { return a + b; } 静态类型语言与动态类型语言对于上面这个简单的加法实现全然不同。静态类型语言。比如Java。语言的编译器在编译时就已经进行类型检查,所...

weixin_34380781的博客 174

InvokeDynamic解释

它的基本原理是通过一个称为“引导方法(bootstrap method)”的特殊方法来动态地选择目标方法,并返回一个称为“调用点(call site)”的对象。在运行时,当调用Lambda表达式时,JVM会使用调用点对象来动态地选择目标方法,并执行Lambda表达式的逻辑。具体来说,当编译器遇到Lambda表达式时,它会生成一个函数式接口的实现类,并在该类中生成一个方法来实现Lambda表达式的逻辑。是Java虚拟机中的一种指令,用于在运行时动态地调用方法,提高动态语言在JVM上的性能和灵活性。

weixin_44143668的博客 343

模型优化系列——模型剪枝/量化概述

模型优化目的:通过减少模型大小,提高推理速度等使模型成功部署在各个硬件中并实时有效运作。

qq_61210574的博客 1299

Experion PKS系列开发:I_O模块_ExperionPKS与第三方I-O模块的集成

通过上述步骤,可以成功将第三方I/O模块集成到Honeywell Experion PKS系统中,实现对现场设备的监视和控制。集成过程中需要注意选择合适的第三方模块,配置正确的通信参数,编写正确的控制逻辑,并进行充分的测试,以确保系统的稳定性和可靠性。不同的通信协议(如Modbus、Profibus、Ethernet/IP、CANopen、OPC UA)有其独特的配置和编程方法,但总体流程相似。在实际应用中,根据项目需求选择合适的协议和模块,可以有效提高系统的灵活性和适应性。

zhubeibei168的博客 1110

Java8学习笔记(2) -- InvokeDynamic指令

详细分析invokedynamic指令

zxh的专栏 1万+

15、人工智能社会学:关系视角下的机器相遇

本文探讨了将人工智能视为社会主体的可能性,提出了一种关系视角下的人工智能社会学。通过结合卢西亚娜·帕里西、艾伦·图灵和乔治·赫伯特·米德的理论,强调不确定性在人工智能运行中的核心地位,并分析了人工智能如何通过与社会环境的互动催生新奇性,从而拓展社会学的研究范畴。文章还讨论了人工智能对社会结构和社会互动的影响,以及其作为社会主体所带来的理论和实践意义,为未来人工智能社会学的发展提供了方向。

pea55的博客 75

java invokedynamic_理解 invokedynamic

inDy(invokedynamic)是 java 7 引入的一条新的虚拟机指令,这是自 1.0 以来第一次引入新的虚拟机指令。到了 java 8 这条指令才第一次在 java 应用,用在 lambda 表达式中。 indy 与其他 invoke 指令不同的是它允许由应用级的代码来决定方法解析。所谓应用级的代码其实是一个方法,在这里这个方法被称为引导方法(Bootstrap Method),简称 ...

weixin_39707612的博客 542

利用autojs制作抢购支付宝消费劵的手机脚本

前期准备工作 1.打开支付宝,点击中间的抢消费券的广告 2.点击左上角,将抢购页面添加到首页 3.查看支付宝首页是否出现消费劵 . autojs代码 "auto"; functiontaskstart(){ sleep(1000); launchApp('支付宝'); toast("正在打开支付宝应用"); sleep(1000); varxf=textContains("消费").findOne().bounds(); ...

洛阳泰山的博客 1万+

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Java中的invokedynamic

Java中的invokedynamic

sanmansan的博客 507

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Java中的动态语言支持:InvokeDynamic与JVM的性能优化

是Java为了支持动态语言而引入的一个重要特性,它通过延迟方法调用的绑定,提高了动态语言在JVM上的运行效率。虽然使用起来有一定的复杂性,但它为动态语言提供了更大的灵活性和性能优势。未来,我们可以期待在API易用性、调试支持和性能优化方面有更多的发展。

weixin_41455464的博客 844

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

java groovy集成_Java集成Groovy性能优化与最佳实践初探

Java集成Groovy性能优化与最佳实践初探一.使用场景与目的:Groovy是运行在JVM上的和Java类似,但是写法更精简的,动态类型语言。Java集成Groovy在我们这里使用的场景是业务同学自行编辑配置的DSL转成groovy为目标语言,而groovy需要最终集成到我们的MWP-ROOTER Java代码中。由于这里集成到MWP后用户的调用量会比较大,同时对性能有要求(甚至会担心一些gro...

weixin_39671405的博客 2404

理解 invokedynamic

inDy(invokedynamic)是 java 7 引入的一条新的虚拟机指令,这是自 1.0 以来第一次引入新的虚拟机指令。到了 java 8 这条指令才第一次在 java 应用,用在 lambda 表达式中。 indy 与其他 invoke 指令不同的是它允许由应用级的代码来决定方法解析。所谓应用级的代码其实是一个方法,在这里这个方法被称为引导方法(Bootstrap Method),简称 ...

weixin_34242331的博客 313

invoke*(原有的4中字节码指令)和invokedynamic区别

invoke*(原有的4中字节码指令)和invokedynamic区别     invokedynamic的出线就是要打破原来固化在虚拟机里面的方法调用的模式,把方法调用的主动权从虚拟机移交给程序员,让程序员可以更加灵活的调用方法,可以更好的支持语言的动态性。 打个比方: 有个超市里面各种东西,你要去买东西,给你口袋里塞一些钱,但是没告诉你多少

Jarvan_Song的博客 909

java groovy_Groovy Java同伴–简介

java groovy 我们中有些人来自脚本语言,例如Python,Ruby或Perl。 Java中的几乎所有事物都令人着迷,但是小事情使我们感到恼火。 Java是一种冗长的编程语言,编写功能类似于脚本的程序很麻烦。 处理诸如XML,json甚至Strings之类的东西并不是很方便。 应该直截了当的事情很尴尬。 感谢上帝,有很多第三方库,例如Apache Commons,Guava,Gso...

148

invokedynamic和java.lang.invoke包 分别是拿来干什么用的?

invokedynamic和java.lang.invoke包 分别是拿来干什么用的?

liuruiaaa的博客 353

动态类型的语言支持--invokedynamic

invokedynamic是为了实现lambda表达式做的技术准备。动态类型语言动态类型语言的关键特征是它的类型检查的主体过程是在运行期而不是编译期进行的,例如:APL、Clojure、Erlang、Groovy、JavaScript、Jython、Lisp、Lua、PHP、Prolog、Python、Ruby、Smalltalk和Tcl等等。那相对地,在编译期就进行类型检查过程的语言,如C++和J

limerick1718的博客 476

groovy 2.5.4_Groovy 2.0终于来了–专访项目负责人Guillaume Laforge

如今,流行的动态语言Groovy终于发布了2.0版 ,这标志着其发展的重大变化。 此里程碑式里程碑的新功能包括静态类型检查器,它可使编译器告诉您代码的正确性,静态编译和新的模块化方法。 在Project Coin和Invokedynamic中,JDK 7也有了一些飞跃,从而保持了Groovy与Java的紧密联系。 SpringSource的Groovy项目负责人Guillaume Lafo...

331
上一篇: Java8学习笔记(2) -- InvokeDynamic指令
下一篇: Java8学习笔记(4) -- Lambda表达式实现方式
zxh0
博客等级 码龄14年 351粉丝 60原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值