Questions tagged [invokedynamic]

For questions about the invokedynamic bytecode instruction of the Java virtual machine.

78 questions
3
votes
1 answer

Retrieve Array Clone Method Handle Through a Public Lookup

Recently, I attempted to access the clone method of an array type through the java.lang.invoke library. This proved unsuccessful. The clone method in sample is one such as this: int[] a = new int[]{1, 2, 3, 4}; int[] b = a.clone(); I wish to create…
Obicere
  • 2,999
  • 3
  • 20
  • 31
3
votes
1 answer

Chain method calls using MethodHandles and invokedynamic

Think of a dynamic, predicated aspect language. Aspects could be invoked (i.e., methods) instead of or before and after an original method. These aspects are switched on and off which happens at runtime. It could even be, that multiple aspects want…
lschuetze
  • 1,218
  • 10
  • 25
3
votes
1 answer

InvokeDynamic for Grails

Is it possible to use InvokeDynamic for Grails? If so, what versions of Grails, Java, etc. are compatible? What is the procedure to set it up? If it's not possible, when might InvokeDynamic support be added to Grails 2.x and/or 3.x? I haven't found…
XDR
  • 4,070
  • 3
  • 30
  • 54
3
votes
2 answers

MethodType transformation for MethodHandle to accept Array Object paramters

I want to adapt String.startsWith from (String, String)boolean to (String[])boolean, so that it can accepts String[] parameters, in which first two parameters will be mapped to the (String, String). Therefore, I wrote below sample code:…
shijie xu
  • 1,975
  • 21
  • 52
3
votes
1 answer

When is invokedynamic actually useful (besides lazy constants)?

TL;DR Please provide a piece of code written in some well known dynamic language (e.g. JavaScript) and how that code would look like in Java bytecode using invokedynamic and explain why the usage of invokedynamic is a step forward here. Background I…
yankee
  • 38,872
  • 15
  • 103
  • 162
3
votes
1 answer

Linkage#registerBootstrapMethod in JDK 7

Back in the preview releases of JDK 7 there was a collection of methods which controled the linkage of invokedynamic call sites in a class called Linkage. For example registerBootstrapMethod. What happend to these in the final release of the JDK?
3
votes
1 answer

Shouldn't having a jit reduce the need for invokeDynamic?

After doing much reading on invokeDynamic, i am still a bit confused.One repeating theme seems to be how Clojure doesn't really need it, or at least need it less than other dynamic language implementations on the JVM (Jruby,JPython,Groovy etc.).I…
GreyGeek
  • 918
  • 5
  • 14
2
votes
1 answer

Where does the extra parameter in a compiled lambda function come from?

I'm trying to figure out exactly how lambdas and closures work in the JVM. To that end, I've tried compiling this simple test case: import java.util.function.*; class Adder { static Function makeAdder(Float a) { return b -> a +…
rwallace
  • 31,405
  • 40
  • 123
  • 242
2
votes
1 answer

Where is the android verifier source code?

Where can I find the source code of the android code verifier? I want to work with invokedynamics but get some VerifyErrors (java.lang.VerifyError: Verifier rejected class ...) from the android verifier. My code works using the normal JVM…
Aura Lee
  • 416
  • 3
  • 11
2
votes
2 answers

How can the methods `makeConcat​` and `makeConcatWithConstants` in `StringConcatFactory` used by directly calling the API?

I believe since Java 9 string concatenation has been implemented using StringConcatFactory. Since this is provided as an API in Java how are the methods makeConcat​ and makeConcatWithConstants in StringConcatFactory used by directly calling the API?…
2
votes
2 answers

How to instantiate an object using LambdaMetaFactory?

I have an interface Action: package action; public interface Action { public String act(); } Class SimpleAction: package action; public class SimpleAction implements Action { String action; public SimpleAction() {} public…
John Doe
  • 157
  • 1
  • 10
2
votes
1 answer

Using "invokedynamic" - What is going on under the hood?

Background I'm currently writing a JVM in C# for purely academic purposes (and maybe to build a mixed .NET and Java/Scala application in the future). Context I write the simple JAVA class: public class test { public static String hello_world(int…
unknown6656
  • 2,765
  • 2
  • 36
  • 52
2
votes
3 answers

ASM cannot pass 'Type.INT_TYPE' as constant Bootstrap Method Argument

Consider the following code that is meant to generate an invokedynamic instruction using ASM: // BOOTSTRAP = new Handle(-> // CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType methodType, Class
Clashsoft
  • 11,553
  • 5
  • 40
  • 79
2
votes
0 answers

Java 8 Update 51 (sun-jdk-8u51) Runtime Fatal Error after null MethodHandle invokeExact call with 448 System::gc Runnable arguments

Summary I was able to compile an interface with a main method that calls a null MethodHandle's invokeExact method with 448 instances of a Runnable method reference (System::gc). When I ran the interface, a fatal error was then detected by the Java…
srborlongan
  • 4,460
  • 4
  • 26
  • 33
2
votes
2 answers

Dynamic Type of InvokeDynamic Arguments

To support dynamic types and method dispatch, my programming language introduces a type called dynamic. When calling a method on a callee whose type is dynamic, the compiler first pushes the callee and all arguments on the stack, and then generates…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79