Questions tagged [invokedynamic]

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

78 questions
184
votes
5 answers

What's invokedynamic and how do I use it?

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?
David K.
  • 6,153
  • 10
  • 47
  • 78
115
votes
3 answers

How is String concatenation implemented in Java 9?

As written in JEP 280: Indify String Concatenation: Change the static String-concatenation bytecode sequence generated by javac to use invokedynamic calls to JDK library functions. This will enable future optimizations of String concatenation…
Mohit Tyagi
  • 2,788
  • 4
  • 17
  • 29
58
votes
4 answers

MethodHandle - What is it all about?

I am studying new features of JDK 1.7 and I just can't get it what MethodHandle is designed for? I understand (direct) invocation of the static method (and use of Core Reflection API that is straightforward in this case). I understand also (direct)…
alexsmail
  • 5,661
  • 7
  • 37
  • 57
16
votes
3 answers

Convert MethodHandle to method reference (here Function)

MethodType methodType = MethodType.methodType(void.class, ByteBuffer.class); MethodHandle handle = MethodHandles.publicLookup().findConstructor(type, methodType); Function = handle; // ??? Is it possible to get the last…
Sormuras
  • 8,491
  • 1
  • 38
  • 64
14
votes
1 answer

Clojure JVM 7/8 improvements

Rich Hickey and others have mentioned that Clojure will not get a significant improvement from the upcoming invokeDynamic planned for JVM 7 or 8, but will see a performance gain from tail recursion. Will tail recursion have any effect on (fn [...]…
Ralph
  • 31,584
  • 38
  • 145
  • 282
14
votes
3 answers

Invoke private method with java.lang.invoke.MethodHandle

How can I invoke private method using method handles ? As far as I can see there are only two kinds of publicly accessible Lookup instances: MethodHandles.lookup() MethodHandles.publicLookup() and neither allows unrestricted private access. There…
Marcin Wisnicki
  • 4,511
  • 4
  • 35
  • 57
13
votes
2 answers

Should I use Groovy's @CompileStatic if I'm also using Java 7

I've read through the "What's new in Groovy 2.0" and I'm a bit confused about when to use @CompileStatic. The article mentions that the @CompileStatic annotation was added for developers who weren't able to take advantage of the invoke dynamic part…
Scott
  • 16,711
  • 14
  • 75
  • 120
10
votes
2 answers

Lambda expressions and anonymous classes don't work when loaded as hidden classes

I am trying to compile and load dynamically generated Java code during runtime. Since both ClassLoader::defineClass and Unsafe::defineAnonymousClass have serious drawbacks in this scenario, I tried using hidden classes via Lookup::defineHiddenClass…
Duff
  • 195
  • 9
9
votes
1 answer

How to invoke constructor using LambdaMetaFactory?

I want to try and avoid reflection for invoking a constructor and am trying to follow the LamdaMetaFactory approach taken in this post - Faster alternatives to Java's reflection My class that I want to construct looks like: interface DBBroker…
adamretter
  • 3,885
  • 2
  • 23
  • 43
9
votes
1 answer

MethodHandles or LambdaMetafactory?

At my job we have a DSL for specfying mathematical formulas, that we later apply to a lot of points (in the millions). As of today, we build an AST of the formula, and visit each node to produce what we call an "Evaluator". We then pass that…
Gui13
  • 12,993
  • 17
  • 57
  • 104
9
votes
1 answer

How to call MethodHandle.invokeExact() with an array of Object[]?

Java's MethodHandle.invokeExact(Object...args) takes a variable-length list of arguments. When I try to pass an array of Object [] instead of a list, though, I get an error. See below: private void doIt() throws Throwable { Method meth =…
ccleve
  • 15,239
  • 27
  • 91
  • 157
9
votes
4 answers

How much will JSR-292 (invokedynamic) do to Groovy performance?

Is there an estimate that says how much JSR-292 will impact Groovy performance?
Kimble
  • 7,295
  • 4
  • 54
  • 77
9
votes
1 answer

grails 2 / groovy 2 / JDK7: how to reap the benefits?

I really love Grails but I was wondering how to get the performance benefits of Groovy 2. The question is how to configure the development and production environments in order to get that "close to Java" performance boost. So, if I setup: * JDK 7 *…
tmanolatos
  • 932
  • 10
  • 16
7
votes
1 answer

Execution of bubble sort is 5 times slower with --indy

I wrote an implementation of bubble sort to play around a bit with Groovy and see if --indy have any noticeable effect on the performance. Essentially, it sorts a list of one thousand random integers one thousand times and measures the average…
Raniz
  • 10,882
  • 1
  • 32
  • 64
1
2 3 4 5 6