Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

February/2020
SunMonTueWedThuFriSat
      1
2345678
9101112131415
161718192021 22
23242526272829
       

[ Archives News
for 'Java Technology' ]

home > news > java technology > calling invokedynamic in java

Calling invokedynamic in Java

DynamicIndy There is no way to invoke invokedynamic using the Java language. So testing invokedynamic is not that obvious if you don#039;t have your own dynamic language. I#039;ve developed a small class DynamicIndy that uses ASM 4.0 (not an official release) to generate a static method that calls invokedynamic. These static method is after converted to a MethodHandle that can be called in Java The code is available at the bottom of this post How to use it ? DynamicIndy defines a method named (judiciously :) invokedynamic that takes a name and a MethodType, a way to specify a bootstrap method (a triple class, method name, method type ) and some optional arguments for the bootstrap method. The following code shows how to create a BigDecimal constant using invokedynamic. This code shows how to use it: public class DynamicIndyTest { public static CallSite bsm(Lookup lookup, String name, MethodType methodType, Object arg) { System.out.println(construct the BigDecimal constant +arg); return new ConstantCallSite( MethodHandles.constant(BigDecimal.class, new BigDecimal(arg.toString()))); } public static void main(String[] args) throws Throwable { DynamicIndy dynamicIndy = new DynamicIndy(); MethodHandle mh = dynamicIndy.invokeDynamic(_, MethodType.methodType(BigDecimal.class), DynamicIndyTest.class, bsm, MethodType.methodType(CallSite.class, Lookup.class, String.class, MethodType.class, O...


Date: January, 07 2011
Url: http://www.java.net/blog/forax/archive/2011/01/07/call-invokedynamic-java


Others News

©2002-2019Java-Virtual-Machine.net it | website generator | mobiriseextensions.com | easyhtml5video.com | image slider